Андрей
select_related will work if i want to reduce queries from B and C models, to get some info from A model like: c = C.objects.filter(a_id=1).select_related('a') print(c.a__some_info)
Cacio Lucas
How can I make a queryset to return a model entity and a count of how many times it appears as fk in another model table?
.
Can you show me a sample site made with django?
Sergey
Can you show me a sample site made with django?
You can find a lot of examples in github
Cacio Lucas
You try to count? Please explain again:)
Yep, it worked, it was actually pretty simple, I just didn't know about the "annotate" method
Cacio Lucas
Thanks anyways :)
Cacio Lucas
I'm trying now to annotate a field that should be (timedelta(days=F('integerfield))+F('datetimefield)), but It's not working, does anyone know how can I do it?
Cacio Lucas
http://linkode.org/#BPGSpzIBGxSMFCkyACMo7
Shreehari
Hey guys, if anyone has a detailed hands-on guide on ModelViewSet then please share
Mirco
Hey guys, if anyone has a detailed hands-on guide on ModelViewSet then please share
What didn't u understand about it ? The official doc explains it well enough
Shreehari
What didn't u understand about it ? The official doc explains it well enough
i understood whatever was in the docs. Just trying to grab more info
Shreehari
Frankly i am not able to find much difference between modelviewset and generic views.
Mirco
Frankly i am not able to find much difference between modelviewset and generic views.
GenericViews don't cover all scenarios, I mean with the ViewSet based on your model you have already a full CRUD
Doragonsureiyā
okay thanks
You're welcome! 😊
Anonymous
Hello friends. Is it possible translate the URL’s with Rosetta ? Example: domain.com/es/contacto , Domain.com/en/contact?
عــمــر
I have a problem, i have path /<token>/ Then its shows ) 1 pattern tried not found
عــمــر
Why ? Every think its correct i dont know whats is the problem!
Anonymous
Check it again
عــمــر
I checked it
عــمــر
Every think correct, and i try to change it
Rocky
How to add external css file in django...?
😇ANGELO™️🎧
How to add external css file in django...?
Make it a static file. And connect it in the main settings.py file that you created. It's found in the last section known as STATIC. I'd there are images you could also store it there. DM me and let's talk if you still can't do it
عــمــر
How can i change the data when i have a model form I want to change the data before form.save()
عــمــر
When i edit the “ form.data “ its show that i cant edit it
Lucid
How can I get data from uploaded excel file then sum up the specific fields entities
Lucid
I tried alot to find the appropriate and implemented some but didn't get the desired output I would be very grateful if anyone would give me some guidelines
Anonymous
maybe use pandas
Lucid
maybe use pandas
Yeah I'm also considering it
Lucid
Could you please elaborate more which functions specifically
Lucid
use django-import-export
That's for upload and retrieve right?
Anonymous
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_excel.html I believe its the read_excel function
Anonymous
no problem
Anonymous
I have hosted my Django app on Heroku but I have a questions 1. how can I access my app database now that's on heroku. 2.Django gave me a secret key how can I make my repo public without revealing this Thanks. This is my first Django project
հօรรεiռ
hi is there a way to use datatables in django?
cj
U serious ?
seems that people are banned from using Google/DDG ¯\_(ツ)_/¯
հօรรεiռ
Mirco
yes😹
Come on, open Google or DDG and have a quick search or just start reading documentation
հօรรεiռ
cj
i searched but didn't find anything
you liar, it's literally the first result on Google
Mirco
i searched but didn't find anything
So you firstly have to improve your searching skills
հօรรεiռ
i found something but they were not for admin panel
cj
i found something but they were not for admin panel
you never asked here "for admin panel"
հօรรεiռ
yes sorry
cj
so, people ask for X thing, but they really want to do Y thing... 🤦🏻‍♂️
Mirco
i found something but they were not for admin panel
Honestly if you don't know how Django uses databases, thinking about admin panel is faaar from what u need right now
R
I have hosted my Django app on Heroku but I have a questions 1. how can I access my app database now that's on heroku. 2.Django gave me a secret key how can I make my repo public without revealing this Thanks. This is my first Django project
For the second question I can recommend you to use different environment. Create file(don't forget to add it in your .gitignore) with private data of your project, then open settings.py and rewrite security variables by calling it from your personal file. Here is library which may help you https://django-environ.readthedocs.io/en/latest/
cj
Honestly if you don't know how Django uses databases, thinking about admin panel is faaar from what u need right now
he asked for datatables actually, which is pretty straightforward to use, just importing a JS file 🤷🏻‍♂️ but yes, you're right, he doesn't have enough searching skills
հօรรεiռ
ok thanks guys
Mirco
thank you
https://12factor.net/ A must to read
Doragonsureiyā
ok thanks guys
You're welcome! 😊
Someone
Hey, I am working on payment module. Integrating with payment gateways.. What design pattern should I follow for good code and best performance.. As of now am integrating only one gateway, but in future we will add multiple gateways, coupon system, running offers and incentives on orders, etc. I would like to start with all those in mind, however am not sure which pattern or method to use for good code and good performance. Any suggestions?
Anonymous
For design it'll depend on design of you database whether you have a separate gateways for coupons and orders ...
Oleg
Guys, how to get to know if self-referecing onetoone field is already referenced by another object? (I need to handle this case: "duplicate key value violates unique constraint")
Oleg
I know that it's easy to get rid of needless objects (that are already have reference from somewhere else) in filter (with pk__isnull) Database.objects.filter(db_dr_field__pk__isnull=True) but how to apply it to one object and check only one object reference? I want something like: obj.related_name__pk__isnull
Iran
Hello I need deploy django pdf
cj
Hello I need deploy django pdf
no, you don't need that
Sumit
Hello everyone, I want to know how to identify the device in django, my concern is that if a user logged in with another device , a device verification code has to be sent on his email.