Val
so from the above how can i achieve this from the instrction
Bagdat
def say_hello(name):
def say_hello(name="there"): return "Hello, %s!" % name
Val
thanks but can u please do a little explanation
Bagdat
thanks but can u please do a little explanation
Method have one variable "name" witch has default value "there". When you call method without args , the variable will use default value. If you pass args, default value will be overwritten and variable will have new value
Val
import unittest; class Test(unittest.TestCase): def test_returns_tuple(self): isogram = is_isogram('abolishment') self.assertIsInstance(isogram, tuple, msg='Does not return a tuple') def test_checks_for_isograms(self): word = 'abolishment' self.assertEqual( is_isogram(word), (word, True), msg="Isogram word, '{}' not detected correctly".format(word) ) def test_returns_false_for_nonisograms(self): word = 'alphabet' self.assertEqual( is_isogram(word), (word, False), msg="Non isogram word, '{}' falsely detected".format(word) ) def test_it_only_accepts_strings(self): with self.assertRaises(TypeError) as context: is_isogram(2) self.assertEqual( 'Argument should be a string', context.exception.message, 'String inputs allowed only' ) def test_empty_string_input(self): word = " " self.assertEqual( is_isogram(word), (word, False), msg='Empty string not a avalid isogram' )
Val
def is_isogram()
Val
please what should be the function to give out a word that appear twice?
Lapanit ☃️
Use pastebin avoid spam
Anonymous
Yeah
Val
https://pastebin.com/fePniS59
Abhi
i am writing test code to check if a url is working fine
Abhi
def test_post_list(self): response = self.client.get('posts/search/') self.assertEqual(response.status_code, 200)
Abhi
i am getting error as it is giving "302 status code" error
Abhi
instead of 200
Anonymous
What is self. Client
Abhi
when i hitting the same url in Postman, it is giving "200 status code", what might be the error
Abhi
What is self. Client
it is used in unit testing
Abhi
you return nothing?
why should i return
Abhi
it should just check if that url is working right ?
inchidi
it should just check if that url is working right ?
how if the url is okay? you will give no response (302) right?
Anonymous
I don't know about unit testing
Val
https://pastebin.com/e1rMxA14
Val
Create a class called ShoppingCart. Create a constructor that has no arguments and sets the total attribute to zero, and initializes an empty dict attribute named items. Create a method add_item that requires item_name, quantity and price arguments. This method should add the cost of the added items to the current value of total. It should also add an entry to the items dict such that the key is the item_name and the value is the quantity of the item. Create a method remove_item that requires similar arguments as add_item. It should remove items that have been added to the shopping cart and are not required. This method should deduct the cost of these items from the current total and also update the items dict accordingly. If the quantity of items to be removed exceeds current quantity in cart, assume that all entries of that item are to be removed. Create a method checkout that takes in cash_paid and returns the value of balance from the payment. If cash_paid is not enough to cover the total, return Cash paid not enough. Create a class called Shop that has a constructor which initializes an attribute called quantity at 100. Make sure Shop inherits from ShoppingCart. In the Shop class, override the remove_item method, such that calling Shop's remove_item with no arguments decrements quantity by one.
inchidi
#starterpack
Group Butler
New to Django? here is some resource to start Official docs tutorial Step by step tutorial Video tutorial Another video tutorial Books Django by Example Tango With Django
inchidi
welcome
Agus
thank you
Django Bot
>> Blogs - Install Django on Linux Ubuntu
inchidi
true 😂
inchidi
That url is returning http response
redirecting to another url?
Abhi
It is not
Anonymous
guys
Anonymous
I am using modelforms
Anonymous
and now I add two more fields in it
Anonymous
which aren't in model
Anonymous
what will happen
Anonymous
1. If I call .is_valid()
Anonymous
2. form.save()
Anonymous
ofc there are two more fields
Anonymous
I guess form will be valid
Anonymous
but what about saving in model
Abhi
anyone have used django-google-analytics ?
Abhi
but what about saving in model
just fetch the data from the submitted data in the form, and why make instance of your model then call instancename.create() function
Abhi
ImportError: No module named 'django_google_analytics'
Charly
ImportError: No module named 'django_google_analytics'
it seems that you don't have the module installed
Charly
but reading the doc: https://github.com/clintecker/django-google-analytics
Charly
you can see that you need to import the module with the name 'google_analytics'
Abhi
@Carlangueitor where do i have to import it ?
Charly
Where are you importing it?
Abhi
i am not importing anywhere
Abhi
as soon a i installed the app and tried to run the server
Abhi
i am getting that error
Charly
how do you installed the app?
Lapanit ☃️
is mysql-connector available to install with brew
Lapanit ☃️
?
Abhi
@Carlangueitor i installed it using pip
Abhi
pip install django-google-analytics
Charly
and next?
Abhi
put that 'djagno_google_analytics' into insalled app
Charly
well, the error it's the same I already said, you are writing 'django_google_analytics´instead of 'google_analytics'
Abhi
@Carlangueitor I tried that too
Abhi
Still not working
Charly
Still not working
Still getting the same error?
Django Bot
>> Jobs - Senior Django Developer
Manish
https://pastebin.com/7Hg0AGeu
Manish
(mydjango)~/mydjango/lib/python2.7/site-packages/django/db/backends $ls base init.pyc postgresql_psycopg2 sqlite3 utils.py dummy mysql signals.py util.py utils.pyc init.py oracle signals.pyc util.pyc (mydjango)~/mydjango/lib/python2.7/site-packages/django/db/backends $
Manish
>> import sqlite3 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/deadzone/python27/lib/python2.7/sqlite3/__init__.py", line 24, in <module> from dbapi2 import * File "/home/deadzone/python27/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module> from _sqlite3 import * ImportError: No module named _sqlite3
Manish
https://pastebin.com/hCfjuhu3
Group Butler
Rudra kicked for flood!
Davo
Haha
Manish
Anyone seen those error
Manish
Nd thnxx for unbanning me
Anonymous
Anyone seen those error
Fixed or help still needed?