Re: Optmized Query

2020-05-27 Thread Soumen Khatua
Now I'm facing one problem whenever I'm trying to iterate a loop I'm getting too many SQL variables. Actually after iterating the loop I want to render all the value in the template. if could you resolve this it would be very good for me. Thank you for your time and response Regards, Soumen On

Re: Optmized Query

2020-05-27 Thread Chetan Ganji
Profile.objects.filter().select_related("user").prefetch_related("location") On Thu, May 28, 2020, 2:01 AM Soumen Khatua wrote: > I also know about this concept but I don't how I can achieve it, Could > you give me an example? > Suppose I have: > > > > > > > > *class Profile(models.Model):

Re: Optmized Query

2020-05-27 Thread Soumen Khatua
I also know about this concept but I don't how I can achieve it, Could you give me an example? Suppose I have: *class Profile(models.Model):user = models.OneToOneField( settings.AUTH_USER_MODEL,on_delete = models.CASCADE, related_name="profile")location =

Re: Optmized Query

2020-05-27 Thread Chetan Ganji
select_related for fk and prefetch_related for m2m in django, you can chain them together Regards, Chetan Ganji +91-900-483-4183 ganji.che...@gmail.com http://ryucoder.in On Wed, May 27, 2020 at 4:51 PM Soumen Khatua wrote: > Hi Folks, > I have many to many relationships and Foreign Key in

Optmized Query

2020-05-27 Thread Soumen Khatua
Hi Folks, I have many to many relationships and Foreign Key in the table, I'm using select_realted(foreign key filed name) to optimize the query but I want to fetch many to many and foreign key at the same time , How I can do this in very optimized way? Thank You Regards, Soumen -- You received