rtg
image_device = models.ImageField(upload_to='static/img/devices/')
rtg
¿Is this correct?
Mani
What's easiest way to redirect to the page back after login was attemped, in @login_required pages ?
I used this, but it stock into login and doesn't go to the back url: return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
Mani
return rediret('/')
No, I'm visiting a page like checkout page as guest Now it's login required, so I have to login. After login, then I want user to go back to checkout page, so he could see content now
Mani
Have you implemented login_required on that view. If so you can go to that page after successful login
the default value is to return to "/" page when log in is done, When user push on login button, instead of going back, it would go to "/"
Anonymous
yes but it doesn't work
How have you defined your login required ..?
Mani
How have you defined your login required ..?
@login_required (login_url = 'login') def checkout(request)
William
@login_required (login_url = 'login') def checkout(request)
Share the webpage URL after the login screen appeared when you select payment something.
William
http://127.0.0.1:8000/login?next=/checkout
See, you got the next parameter in the URL. If login is successful It will go to that checkout page.
Mani
See, you got the next parameter in the URL. If login is successful It will go to that checkout page.
yeah but instead it will go to http://127.0.0.1:8000/ when it's done.
Mani
because i got render("/") in my default login page
William
because i got render("/") in my default login page
Did you add LOGIN_REDIRECT something like this in settings?
Enes
hi all
Mani
I think i missed this point
William
Enes
i have a json data list and i need to show this in template but the json data is coming from ajax
Mani
Then share this
@login_required (login_url = 'login') def checkout(request): sub_total = 0 total = 0 quantity = 0 total_count_in_cart = 0 tax = 0 try: cart_items = CartItem.objects.filter(user=request.user,is_active=True) for cartitem in cart_items: print (cartitem.product.name) sub_total += (cartitem.product.price * cartitem.quantity) quantity += cartitem.quantity tax = sub_total * 0.02 total = sub_total + tax except ObjectDoesNotExist: pass first_name = request.user.first_name last_name = request.user.last_name user_email = request.user.email context = { "sub_total":sub_total, "tax":tax, "total":total, "total_count_in_cart":total_count_in_cart, "first_name":first_name, "last_name": last_name, "user_email": user_email, } return render(request, 'store/checkout.html', context)
Enes
[{"model": "store.product", "pk": 3, "fields": {"name": "Men Shoe", "photo": "products/480...jpg", "photo2": "", "photo3": "", "photo4": "", "photo5": "", "price": 256, "old_price": 534, "details": "These shoes are really cool!", "category": 3, "is_draft": false, "date": "2021-07-15T16:03:14.438Z"}}, {"model": "store.product", "pk": 2, "fields": {"name": "T-Shirt & Jacket", "photo": "products/480..jpg", "photo2": "", "photo3": "", "photo4": "", "photo5": "", "price": 68, "old_price": 534, "details": "These products are comfortable and not ichy", "category": 2, "is_draft": false, "date": "2021-07-15T16:01:50.045Z"}}, {"model": "store.product", "pk": 1, "fields": {"name": "Women's Watch", "photo": "products/..480.jpg", "photo2": "images/items/2021/07/16/00/26/12/.480.jpg", "photo3": "", "photo4": "", "photo5": "", "price": 459, "old_price": 534, "details": "These women's watches are really famous. You can wear even in everywhere.", "category": 1, "is_draft": false, "date": "2021-07-04T16:25:00.463Z"}}]
Enes
how can I truly show items in a loop
Enes
it is for sort by alphabetical
Mani
First, login then try visiting checkout page
I didn't understand what you mean? It's checkoutpage view, I said login is required and path is "login"..
Mani
return redirect(request.GET.get('next')) I used this, works now
William
I didn't understand what you mean? It's checkoutpage view, I said login is required and path is "login"..
Your app itself has authenticated means you don't need to log in again for the checkout page.
Almaz
Hello, everyone! I need help: I have noattributeerror at, although i provided all urls, views and templates. The names of urls also correct. I've been stuck at it for hours and i don't know how to solve this problem
George
F
Almaz
Explain properly. Give us more details about that error
Okay. I'm not at home now, but i will explain properly when i will be at home
Damilola
Guys what do you think about Django + Firebase Versus Django + Postgresql I think psql is robust, feels enterprise level or dare I say production grade. Firebase on the other hand feels fast, lightweight and unreliable in terms of data integrity. Feel free to share your thoughts.
Damilola
Guys what do you think about Django + Firebase Versus Django + Postgresql I think psql is robust, feels enterprise level or dare I say production grade. Firebase on the other hand feels fast, lightweight and unreliable in terms of data integrity. Feel free to share your thoughts.
It's weird that we all feel this in our bones. 😂 I'm just wondering if there are valid arguments that pad the notion or suggests otherwise because scaling Postgresql in terms of storage space may become and issue for large projects and firebase or mongodb may just keep scaling like...
Damilola
you got extra features with postgres. Consensus also says "more robust". i've personally never had issues whatever the sql
Yep. The search accessibility is crazy and contextual text search is one of those things I love about it
Anonymous
hello, what's the problem here, error message 'ItemAdmin' object has no attribute 'urls', https://pastebin.com/Wtfz3hMN, https://pastebin.com/ci8pxb5W
Damilola
Like a screenshot
Anonymous
I can't send screenshot in this group
Anonymous
Also I'm far from home
Anonymous
I'll resend it later
Anonymous
hey guys... can you suggest me from where I can learn how to write advanced level python code... the way it is written in python libraries thanks
Doragonsureiyā
hey guys... can you suggest me from where I can learn how to write advanced level python code... the way it is written in python libraries thanks
Please read the pinned message of the group to know more about this group, the rules and also you'll find resources and learning materials there: https://t.me/Python/1162861
M
https://stackoverflow.com/questions/68406992/nested-query-in-django-orm Can anyone help me?
SOSO
Hi guys! Can anyone help me to ranmdomize QuerySet? pharmacy_employees = PharmacyEmployee.objects.all().filter(pharmacy=ph.pharmacy, date=ph.date) count = ph.number_of_employees rand_employees = random.sample(pharmacy_employees, count) Error: rand_employees = random.sample(pharmacy_employees, count) IndentationError: unexpected indent
SOSO
When i used choices: 'int' object is not iterable
Sergey
Hi all! I interested i have m2m relation. I want to have in admin for model that don't have m2m field, but it referenced in other. So how to call reversed m2m?
Anonymous
Guy i need help with user authentication (login, logout) in django from react form?
Damilola
When i used choices: 'int' object is not iterable
That's because you are randomizing the count not the query set list
highnes
!paste
Doragonsureiyā
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like: - https://del.dog - https://dpaste.org - https://linkode.org - https://hastebin.com - https://bin.kv2.dev If you posted a wall of text, go back and delete it.
highnes
This is my model https://bin.kv2.dev/~60f17d3b410e7c32e6695800 I am trying to get list of users with a specific sponsor_id and payment_status == True
highnes
I couldnot find a way, pliease help
Damilola
Hello I need someone good at generating research topics for big data. e Specifically someone in data science or analytics that does research, project writing and thesis related stuff.
Jaya
Hey can anyone tell how to send messages over chat api
Jaya
POST Periodic GET
Can you sugest me some tutorial or something or give me asn example how to use it
Rohan
POST Periodic GET
Wouldn’t that be troublesome? Like you’ll have to write a polling mechanism to do that periodic get
Damilola
Yh
Rohan
So how to do it
Dis you try anything?
Anonymous
I have 3 many to one, how to configure them in admin panel?
Anonymous
models https://pastebin.com/ci8pxb5W, admin https://pastebin.com/Wtfz3hMN
highnes
User.objects.filter(payprofile__payment_status=True, profile__ref_id = request.user.profile.sponsor_id) Thanks for the help