Ammar
You can do it like so Order.objects.select_related("customer").prefetch_related("detail_order_set").all() Note: If u used related name in your models fieldc change the name in bracets with your related name Then in your template make a loop for each order in orders and show what you want
Juan Carlos
ok. Thank . Ill try it
Juan Carlos
.. I think a dont understand prefech vs select...
Ammar
You may need to make two loop one for orders and one for detail
Juan Carlos
ok
Ammar
.. I think a dont understand prefech vs select...
As i know select related is used on you have one object (like each order belong to one customer ) whereas prefetch_related is used when you have many objects belong to one ( each order can have many detail_order ) Sorry for the bad english In django docs they are explained in a good way
Juan Carlos
what is detail_order_set ?? this shoud be a fk in order ?
Ammar
what is detail_order_set ?? this shoud be a fk in order ?
The field that you used models.forgeinkey() in orm you can fetch the related object by the name followed by set Like if you have Class items: order = models.forgienkey() You can get items for an order using order.items_set You can also specify a name using related_name in the field
Juan Carlos
Ok 👌🏻
Ammar
Docs will help you alot
Juan Carlos
Thanks for helping
Farhan
*Hello*, *I have developed a project in Django and gained proficiency in the basics of DRF (Django Rest Framework). I am seeking guidance on what my next steps should be. Could anyone provide some recommendations?* Thank you.
Farhan
Try creating some api apps
Can you give me some ideas ?
Patrick
Can you give me some ideas ?
Pick a Frontend guy Create a social media webapp having most of the features like profile, post, chat, websocket messages, stories. Create multi vendor e commerce having user and merchant profile, products, orders, multiple payment gateway, merchant chat, vendor panel, maybe additional delivery person webapp with live location for delivery This will be good to showcase on resume/portfolio for both of you + enough complex db structure and reusable content like websockets chat, multi tenant user role management, payment gateways,
RAG
Hi all, I need to learn django. Can you share some free good handson course.
Doragonsureiyā
Hi all, I need to learn django. Can you share some free good handson course.
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
Tuan
Hi all, my company has a PC with window server 2019 installed. Now I want to install Django web app. Which should I use? I'm new with this. Is WAMP ok?
Balde
you know a Django lesson for intermediate
A
Hey I have made a django project, I want to know wat are best options to deploy it with custom domain.
Noddy
Hey I have made a django project, I want to know wat are best options to deploy it with custom domain.
Custom domain means? In general i create a unit service file to start and stop django project running on gunicorn wsgi server
Charly
you can use docker if you want to host it on the PC, just look at some tutorials
It the worst idea to use docker ON WINDOWS to serve an app, a wats eof resources
Charly
So the prefer one is remove window and install Linux on it?
The preferred yes, but as I told you you can use IIS
Caleb
It the worst idea to use docker ON WINDOWS to serve an app, a wats eof resources
maybe but, we don't know their 'company' requirements and resources
Caleb
But why suggest somthing like that then?
just going based on his question
Tuan
Thank you every one, I'm trying install Apache and mod_wsgi
Tuan
On computer with window server 2019
Dullah
Hi all, i am trying to make use of the easy-thumbnails app, But unfortunately i cannot see the image being rendered. What could possibly be the reason for this. {% load thumbnail %} <a href=“{{ image.image.url }}”> <img src=“{% thumbnail image.image 300x0 %}> </a> When I render the image normally it works just fine. I’m using easy-thumbnails==2.8.1
Tuan
So you ignored the advise completely
One of my friend advise this way. I'm confusing
Betsalel
hi everyone please i need someone who can help me on a project of parcel delivery management
Doragonsureiyā
Betsalel
I want to implement multi-users with different roles in my models files and based on the role they will have different interfaces but i struggle with it
Nickita
I have a question about drf-spectacular. I have an endpoint with ChoiceField and DRF makes a response like i want. It accepts and returns a full-value of choice { ... "status": "In stock", ... } But in swagger it renders as short value like: { ... "status": "I", ... } So my question is: How can i render it properly in swagger instead of writing example by myself ?
Mohammad Hossein
Hi. I have a problem in play a sound automatically in template. Although I add autoplay attribute to the audio tag, it does not play sound when the page loads. Plz help me
Km
Hi everyone, here is a concept question regarding where a process should be put? In views.py or serializer.py. Here is a get_product_detail_info.py which could provide the dictionary structure info from outside. I’m not sure if this process that to get the info from outside should belong to serialization, or it is divided into views. Thank you.
Frazil
https://dpaste.org/XKqFz
Shaheen
I need to upload a image without forms.py method , have any possible ways to do that ?
Shaheen
what do u mean without forms ?
creating a custom html form to upload a image in django without using forms.py to create a form
Shaheen
So how backend should answer ? Via API?
Not problem with creating a html form, how to write a views for that and I tried it doesn't work out
Mirco
Not problem with creating a html form, how to write a views for that and I tried it doesn't work out
u can do also without a Django form, inside the view u will have files in request.FILES
Mirco
Can you please write as code
https://simpleisbetterthancomplex.com/tutorial/2016/08/01/how-to-upload-files-with-django.html
Shaheen
Thank you so much
SMM-Member.Uz
Guys how i can check whether user visits first time to web site or not
vaseem cholakkan
guys any orm method to make a queryset ordered before another queryset chatgpt gave first_queryset | second_query but this is not getting me ordered like first_queryset first and second_queryset after that .
Максим
order = ... for seller_order in order.sellers_orders.all():     seller_order.state = 'new'     seller_order.save() order.save() return Response(BuyerOrderSerializer(order).data) Why seller_order.state = 'new' and seller_order.save() Changes state only in db, not in serializer? I see old value of state in serializer.data
SMM-Member.Uz
Can I check device first time visit to site?
Denilson
Hey guys. Somebody have a video tutorial, about, how deploy a django project using Hostinger?
Denilson
Is it a hosting service or vps vendor?
Vps. Because the Hostinger hosting service, don’t support Django.
Sanitizer
Guys, how can I host my Django api
Muflone
Vps. Because the Hostinger hosting service, don’t support Django.
Then use any guide to install your Django project on vps, hostinger is not relevant
Sunil
Hey guys. Somebody have a video tutorial, about, how deploy a django project using Hostinger?
Hostinger Supports Django over VPS.. they have a predefined OS template you can try it and customize as per your requirement.. Makes sure you change all necessary security settings and passwords for your application safety and security. Below is the link for the same.. all the very best.. You can find articles on hostinger site itself. https://support.hostinger.com/en/articles/4965922-how-to-change-the-operating-system-for-your-vps There, you will find the Change Your Operating System section: Choose the one that suits your needs the most: OS with Control Panel - easier to use, especially for beginners Plain OS - option suits advanced users and users who wish to install a custom panel manually Applications - these are Ubuntu-based templates that include the automatic installation of applications such as Django, Drupal, Joomla, WordPress, and more https://support.hostinger.com/en/articles/1583571-what-are-the-available-operating-systems-for-vps
Максим
new_order = order.save() then your_serializer(new_order)
Thanks! I found that object "order" not changes. order = ... for seller_order in order.sellers_orders.filter().all(): seller_order.state = 'new' seller_order.save() Then for seller_order in order.sellers_orders.all(): seller_order.state # 'old'
Sharanbir
AttributeError at /customer/1/ 'None Type' object has no attribute_default_manager' Request Method: GET Request URL: http://127.0.0.1:8000/customer/1/ Django Version: 4.22 Exception Type: AttributeError 'NoneType' object has no attribute_default_manager' Exception Location: C\pythonnnn\Lib\site-packages/django_filters\filterset.py line 175, in init Raised during: home views.customer Python Executable: C:\pythonnnn\python.exe Python Version: 3.11.1 Python Path: [E:\\django_practi\\superset', 'C:\\pythonnnn\python311.zip",
Максим
explain more
order = Order.objects...prefetch_related(...).first() for seller_order in order.sellers_orders.filter(...).all():     seller_order.state = 'new'     seller_order.save() Then for seller_order in order.sellers_orders.all():     print(seller_order.state)  # old value, not "new" but works fine without a filter: order = ... for seller_order in order.sellers_orders.all(): # no .filter() if seller_order....: # filtering     seller_order.state = 'new'     seller_order.save() Then for seller_order in order.sellers_orders.all():     print(seller_order.state) # ok! "new"
Avengers
How to post data in json format at server
דוד
How can i deploy my django project to test it for free?
vaseem cholakkan
How can i deploy my django project to test it for free?
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
דוד
you can use aws
Thank you i will try it