Ali
Hello
local variable 'product_list' referenced before assignment
Hello
Ive got this error... how its possible ? the 'product_list' is inside the block
Hello
To create as what ? As empty list?
Ali
Empty or false
Hello
It’s still doing the same problem.. doesn’t show the product_list. It goes to the except block
Hello
https://dpaste.org/HVXRW there are the changes
Hello
this is the template https://dpaste.org/e1Wif
Maksim
Hi! How solve this problem: ForeignKey(['users.NoName']) is invalid. First parametr to ForeignKey must be.....(AUTH_USER_MODEL)
AℤℐℤℬℰᏦ ☝️
while i < len(elem):
TypeError: object of type 'SimpleRouter' has no len()
Anonymous
Mirco
Arash
Hi. I'm learning Django and I'm using ready-made html css js templates to practice backend with Django. I have been asked a question and that is, what information should I store in the database through the models.py and what information should I store in the folders?
For example, which photos from the website should I store in the database and which should I save in folders?
Koen de
Picasso
Hi! I'm a beginner in django. I'd like to know how to make my nav links render my templates properly
Hello
Hello
Hey everybody!
How to create a list from field that is ‘manytomany’ in specific object ?
Koen de
Picasso
thanks. I just got the answer
Hello
I did it as a global on other func . This is the input of the user
Hello
So how to code if it’s not catch it as a global var?
Hello
https://dpaste.org/ba7XK this is the code
Hello
you can see it on the second fun
Hello
On the cmd I got :
Hello
and give me the option to write
Hello
-> user = FavoriteList.objects.get(email=em)
(Pdb)
Hello
what is mean?
Koen de
Yes! That’s nice. Now, just type: em
to see what “em” is.
Hello
''
Hello
empty string
Koen de
Your inside the Python Debugger now. With “c” you can continue
Koen de
Empty string, you have to find out why em is not set at that point. Maybe the initial code where you to set it is not correct
Hello
so how to keep the input that the user give me?
Koen de
It is why I do not like/use globals ;-)
Hello
There is another way?
Koen de
You can try to read the email from the request in the productlist method.
Or find out why it is not set in ask_productlist.
Play around with pdb
https://docs.python.org/3/library/pdb.html
Anonymous
Is it ok: .prefetch_related().select_related()?
Anonymous
It works but I think there is better way to do it
Elhem
Swagger does not require parameters of for login When I came to api/login view There I could find a field where I needed to send "username" and "password"
For LogIn I inherit from KnoxLoginView HOW could I make Swagger require parameters and see Knox ?
Elhem
please i need help
Koen de
Hello
Hello
Hello
I put it like this
Hello
def productlist(request):
try:
pdb.set_trace()
user = FavoriteList.objects.get(email=request.session['email_user'])
product_list = user.favorite_product.all()
except FavoriteList.DoesNotExist:
messages.error(request, "There isn't exist this email adrees. Please create your favorite list")
product_list=None
return render(request ,'product/productlistdetails.html', {'product_list': product_list})
Koen de
Hello
and when I get on the cmd pdb : request.session['email_user']
Hello
get again empty, maybe because its before?
Koen de
Hello
But on the web it still don’t catch it
Koen de
You could investigate the order of the methods, which one is called before the other
Koen de
Hello
The input from the user , the email
Hello
Koen de
Ok .. I try
Investigate if the email is actually set during ask_productlist too
Hello
I check , I put the pdb after when its put to see the allocate , return empty string again...
Hello
def ask_productlist(request):
if request.method == 'POST':
email = request.POST.get('email','')
request.session['email_user']= email
pdb.set_trace()
return redirect('productlist')
return render(request, 'product/ask_productlist.html')
Sayidbek
Hey there, how can I create sign_up function where peope sign up with raw HTML?
Koen de
Hello
Ok I try thank you 🙏🏻
Anonymous
I'm unable to update my model. Like for example, if I create a model and save it and migrations it works fine. But If I add another field to model and try to make migrations an error pops up
"It's impossible to add non-nullable field"
How to solve this error?
Anonymous
Ali
Tried it but it ddnt work
Remove all records and try again
If you get the error again, you can delete the database and recreate it
Anonymous
Anonymous
Ali
Koen de
Still the same error
“It’s impossible to add non-nullable field” is not the complete error…
But it seems you already got your solution with a fresh database
Anonymous
IM~Exynos
How to create custom logs for specific function via model.
Koen de
How to create custom logs for specific function via model.
Well I like Sentry to handle my logs.
But “django-db-logger” is my second best. https://github.com/CiCiUi/django-db-logger
Why should you reinvent the wheel?
In any other case you can create a simple Model with a textfield and report your logging there.
You can use django-db-logger aa inspiration and even copy+modify their codebase as their WTFPL-license allows that.
The_one_ring