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?
Doragonsureiyā
~:$
~:$
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)
Anonymous
Guys nested serializer is not working please help
Anonymous
Nested one is giving error
Javi
Is like that, but the first one works
Javi
Nop
Javi
.select_related('fkattr').prefetch_related('fkattr__mym2mAttr')
~:$
Cimara
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?
Anonymous
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
Doragonsureiyā
Ghorz
Rohit
Suggest me some django project
Владислав
Guys, what construction should you use in bs4 if there is no element in html?
Harish
Rohit
Harish
Stock Trading WebApp
Note Taking apps
Wordpress clones
Netflix clone
Ola
Harish
😂
Sai
Sai
Or video streaming
Rohit
Shanks
Jerome
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?
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?
Gowtham
Gowtham
Gowtham
🙏
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?
Anonymous
https://del.dog/text-product-2
Somebody help please
Beka
Add parameter action and set your form url there
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})
Mukesh
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})
the code
Anonymous
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 %}
Ghorz
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)
You can listen in on the signal with post signal and Ama am option exist from the admin.py file
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
Charanjit Singh
It will automatically translate your text on webpage according to language
AMIN
Can you please explain more