Javi
You can answer my query.
Select related is only for ForeignKey and OneToOne, and returns always One object.... What query do you want to execute in only one row?
~:$
Select related is only for ForeignKey and OneToOne, and returns always One object.... What query do you want to execute in only one row?
Yes i know. The returned One object has further manytomany relation with other models. I want that i can fetch them as well.
~:$
Yes
Really Nice. Appreciated
Max
Hello everyone, tell me which way to dig. There are two models. Books and categories. There are two views with classes, list view. Each renders its own. One book, second category. In the urls file, you need to specify the template and the view that renders it. But I need both categories and books to be displayed on the index page)) help with advice)
Javi
Yes i know. The returned One object has further manytomany relation with other models. I want that i can fetch them as well.
Haaa, ok... You can try with: prefetch_related(Prefetch('yourfkAttr__yourm2mAttr', queryset=Yourm2mClass.objects.filter(st))
Anonymous
Guys nested serializer is not working please help
Anonymous
Nested one is giving error
~:$
Haaa, ok... You can try with: prefetch_related(Prefetch('yourfkAttr__yourm2mAttr', queryset=Yourm2mClass.objects.filter(st))
Appreciated. But..... Can it be like????? select_related('fkAttr', queryset=FkClass.objects.prefetch_related('mym2mAttr'))
Javi
Is like that, but the first one works
~:$
Is like that, but the first one works
I know that the first query will work that you wrote. But i want the query that i wrote. It is possible.
Javi
Nop
Javi
.select_related('fkattr').prefetch_related('fkattr__mym2mAttr')
Shanks
There are multiple forms in a single page posting of one form resulting in posting of other form with blank values and that form with values. So how to detect which form is getting posted?
Shanks
One more question?
Shanks
What if a form is base in all pages? How to detect it?
Harish
While using multiple database connections and migrate, why does it create empty tables in every database connection?
V
Does anyone know about modal form submissions?
Doragonsureiyā
Does anyone know about modal form submissions?
Don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello, I need help on $z" Just ask about your problem directly! With ~90,000 people here, the probability that someone will help is pretty high. How to ask smart questions: http://catb.org/~esr/faqs/smart-questions.html
Harish
Can you elloborate little more
Assume we have 3 database connections db_1, db_2 and db_3 db_1 is marked as default I've create a model my_custom_model_1 as part of app_1 and db_1 my_custom_model_2 as part of app_2 and db_2 my_custom_model_3 as part of app_3 and db_3 using the proper routers and configurations however, when I run migrate I'm able to see my_custom_model_1,2 and 3 as part of db_1 and db_2 and only my_custom_model_3 in db_3 across all databases I'm able to also see django_migrations, auth_dbs etc why does this happen? is there a way of configuring it such that it doesn't On database inserts they hit the write tables in the configured databases (thanks to the routers) however, empty ones are created
Sujit
Hey anyone online? need some help
Ghorz
No
😂😂😂😂🤣
Rohit
Suggest me some django project
Владислав
Guys, what construction should you use in bs4 if there is no element in html?
Harish
Suggest me some django project
clone of any web-app you use
Rohit
Harish
Stock Trading WebApp Note Taking apps Wordpress clones Netflix clone
Harish
😂
Sai
Or video streaming
Rohit
Harish
Does anyone know how to raise signals when interacting with Django Admin I've figured out how to overload post_save. but not pre_init, post_init class CustomMultiDBModelAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): # print(obj, change, self.using) obj.save(using=self.using) # obj.__class__.get_or_create(**obj.__dict__) # super().save_model(request, obj, form, change) def delete_model(self, request, obj): obj.delete(using=self.using) # super().delete_model(request, obj) def get_queryset(self, request): return super().get_queryset(request).using(self.using) def formfield_for_foreignkey(self, db_field, request, **kwargs): return super().formfield_for_foreignkey(db_field, request, using=self.using, **kwargs) def formfield_for_manytomany(self, db_field, request, **kwargs): return super().formfield_for_manytomany(db_field, request, using=self.using, **kwargs)
Davide
Hi, do you know how you can exclude a template part when using extends "base.html" in a file?
Davide
Solved thanks
Agent Q
I hope he's not in SO
Schohreh
Hi Does any one knows how to import or export “ document “ In Django ? I’m doing with RESTer It can upload picture But not any other data like Excel file I need to upload an excel file also
Schohreh
I hope some body answer this
Michael the wolf 🐺
Use base64?
Schohreh
Use base64?
Can you explain more ?
V
Yes
How can i bring foriegn key values to modal forms? I have a modal form which is included in base template and i don't know how to bring foriegn key values to select tag in html
Gowtham
Any best way to render charts on mail by Django?
M
Any best way to render charts on mail by Django?
you can use plotly howvever i think limit is it will not go in body, you can always send as attachement
Gowtham
you can use plotly howvever i think limit is it will not go in body, you can always send as attachement
Nice idea I just saved the chart as image by plotly and attached in mail body. It worked easily.
Gowtham
🙏
M
Nice idea I just saved the chart as image by plotly and attached in mail body. It worked easily.
good , actually i also do the same , adding attachment is giving more interactive feature to receipient of email
Gowtham
Yeah. @moriadelatorte
Anonymous
Hello Guys i want to use BASE_DIR from settings.py in my views but it says " no module named 'project-name' "
Anonymous
Can anybody help?
Ray of Hope
Yeah. @moriadelatorte
How can we send email using django ?
Anonymous
https://del.dog/text-product-2 Somebody help please
Beka
https://del.dog/text-product-2 Somebody help please
You did not specify parameter "action" which is goes to your view. You have only parameter "method".
Beka
Add parameter action and set your form url there
Charanjit Singh
Hello Guys i want to use BASE_DIR from settings.py in my views but it says " no module named 'project-name' "
First you have to import settings. To import settings From django.conf import settings Then to use base_dir Name = settings.Base_Dir
Mukesh
I am trying integrate razorpay with Django 3.1 but gettinig AttributeError: 'str' object has no attribute 'post' while order_detail = client.order.create(data=data)
Mukesh
order_store = Order(user_id=customer_id, prod_id=product_id, quantity=quantity, attribute_value=attribute_value, order_job_title=Job_title, order_desc=Order_Detail, address=User_Address, state=State, city=City, postal_code=Postal_Code, product_img=TemplateValue, order_price=order_price) if order_store: order_store.save() o_id = Order.objects.get(order_id=order_store.order_id) payment_store = Payment(order_id=o_id) payment_store.save() client = razorpay.Client('rzp_test_Cut6mUJgrjfQU', 'LSNlrKrH0NoUq8Y9rEUbg27') print(client) data = { 'amount': order_price * 100, 'currency': "INR", 'receipt': 'Order for ' + str(o_id.order_id), 'notes': { 'name': o_id.user_id.first_name + o_id.user_id.last_name, 'Payment_for': o_id.prod_id.prod_Name } } print(data) order_detail = client.order.create(data=data) print(order_detail) return render(request, 'user/payment.html', {'order_store': order_store})
Tukhtamurod
inside fields include 'user' and inside serilazer just specify user=UserSerializer() Note you have to create UserSerializer first with the fields you want to include
Tukhtamurod
What kinda attribute is it?
Tukhtamurod
Delete it and try my way
Tukhtamurod
You are telling Serializer to serialize an Object as an attribute, You have to create UserSerializer first and include that serializer as an attr not User class
Anonymous
I am getting user in response but only id
Tukhtamurod
I am getting user in response but only id
Yes you do, what are u expecting dude🤦🏻‍♂️🤦🏻‍♂️I am telling you again delete user=User and instead write user=UserSerializer; create UserSerializer: model=User fields=["username", "image"]
Doragonsureiyā
🚫 ‎CCD Days - Team [1677820934] is already banned.
Enigma
hi everyone i got a form and a view for it and i want to add error if user wallet balance doest have enough money! all the parts works well but it wont add any error at the form my form add error code in view is this : product_purchase_form.add_error('count_number', "You don't have enough balance in your wallet for purchase") the "count_number" is the form filed which i want to add error under it and my html code is like : {{ form.count_number }} {% for error in form.count_number.errors %} <p style="color: red">{{ error }}</p> {% endfor %}
Harish
You can listen in on the signal with post signal and Ama am option exist from the admin.py file
But how do you dispatch it from Django admin console? I've implemented it for pre_save and post_save But not pre_init and post_init
AMIN
Hi, I'm working on a 2 language project i need some help, I need to change language by region how can I do that in django . I mean when the ip is "x" render one template else other template
Charanjit Singh
It will automatically translate your text on webpage according to language
AMIN
Can you please explain more