Re: def post in ListView

2021-11-24 Thread Lalit Suthar
oh cool :D this is looking more pretty

On Thu, 25 Nov 2021 at 02:49, bnmng  wrote:

> Thanks, though, Lalit.
>
> I realized I don't event have to do what I was originally doing.  I can
> just do this:
>
> def post(self, request, *args, **kwargs):
> return super().get(request, *args, **kwargs)
> Then the post params are still available to the queryset method
> def get_queryset(self):
> if self.request.POST.get('query_submitted'):
> ... do stuff ...
>
>
>
> On Wednesday, November 24, 2021 at 12:14:21 PM UTC-5 sutharl...@gmail.com
> wrote:
>
>> oh my bad that is available in django rest framework only
>>
>>
>> On Wed, 24 Nov 2021 at 22:41, Lalit Suthar  wrote:
>>
>>> you can use `query_params`
>>>
>>> On Wed, 24 Nov 2021 at 19:04, bnmng  wrote:
>>>
 Hi everyone,

 Is there anything dangerous about this?
 class ItemList(ListView):
 model = Item
 def post(self, request, *args, **kwargs):
 self.request.GET = self.request.POST
 return super().get(request, *args, **kwargs)

 I want to use this to accept filtering parameters from a form in a list
 view template. This ListView also has a get_queryset which returns a
 filtered query based on the parameters

 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/aa7a1392-e388-4727-b412-bd1329daa6c4n%40googlegroups.com
 
 .

>>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9e6d1ed0-0061-4e88-a715-c677d300461dn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVF4%3D-MsR_eVDk1JEU%3DmP34eFGRmukCkv_T0cgTaafE1-w%40mail.gmail.com.


RE: Permissions Model Inefficiency Killing DB

2021-11-24 Thread Mike Dewhirst
Do you think this is a consequence of permission complexity?I have 
instinctively avoided individual permissions for purely management reasons and 
stuck to user membership of auth groups (roles) and given permissions 
exclusively to groups.That postpones lookups to when they are needed.I can't 
imagine how difficult it would be to unravel your scenario and impose group 
permissions.Sorry I can't help with your actual question.CheersMike--(Unsigned 
mail from my phone)
 Original message From: Ryan Skadberg  Date: 
25/11/21  07:35  (GMT+10:00) To: Django users  
Subject: Permissions Model Inefficiency Killing DB Hi All -  Running Django 
2.2.24 (Yes, I know, we are working on moving to 3.2)  I've noticed some stalls 
in startup and finally have tracked it down.  It appears when permissions are 
imported, it checks EVERY user for permissions, NOT just the ones in the 
user_user_permissions table.  When you have 30k users in your DB this causes at 
least 60k SQL calls on startup.They all look something like this:2021-11-24 
19:04:46.725 UTC [39] LOG:  duration: 0.344 ms  statement: SELECT 
"auth_group"."id", "auth_group"."name" FROM "auth_group" INNER JOIN 
"user_groups" ON ("auth_group"."id" = "user_groups"."group_id") WHERE 
"user_groups"."customuser_id" = 273452021-11-24 19:04:46.728 UTC [39] LOG:  
duration: 0.379 ms  statement: SELECT "auth_permission"."id", 
"auth_permission"."name", "auth_permission"."content_type_id", 
"auth_permission"."codename" FROM "auth_permission" INNER JOIN 
"user_user_permissions" ON ("auth_permission"."id" = 
"user_user_permissions"."permission_id") INNER JOIN "django_content_type" ON 
("auth_permission"."content_type_id" = "django_content_type"."id") WHERE 
"user_user_permissions"."customuser_id" = 27345 ORDER BY 
"django_content_type"."app_label" ASC, "django_content_type"."model" ASC, 
"auth_permission"."codename" ASC I have 677 rows in user_user_permissions with 
a minimum customuser_id of 0 and a max of 27346.  When I start up my tests, 
instead of looking at the 677 users that have permissions in the 
user_user_permissions table, it checks all 27346.  As there is nothing in the 
table for them, this is super super inefficient.It appears that the SQL is 
doing something like:select id from public.userAnd really should be doing 
something like this to minimize SQL calls:select id from public.user where id 
in (select customuser_id from user_user_permissions);which in my case would be 
1/30th of the calls, which would be HUGE for startup (60k to 2k or so).Can 
anyone either explain why this is happening or a way to work around it or if I 
should file a bug?Thanks!Ryan



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0d5aa4db-ccd7-482a-8530-1cc8d76bbcc0n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/619ebdd8.1c69fb81.4b1ac.9e2dSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: def post in ListView

2021-11-24 Thread bnmng
Thanks, though, Lalit.  

I realized I don't event have to do what I was originally doing.  I can 
just do this:

def post(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
Then the post params are still available to the queryset method 
def get_queryset(self):
if self.request.POST.get('query_submitted'):
... do stuff ...



On Wednesday, November 24, 2021 at 12:14:21 PM UTC-5 sutharl...@gmail.com 
wrote:

> oh my bad that is available in django rest framework only
>
>
> On Wed, 24 Nov 2021 at 22:41, Lalit Suthar  wrote:
>
>> you can use `query_params`
>>
>> On Wed, 24 Nov 2021 at 19:04, bnmng  wrote:
>>
>>> Hi everyone,
>>>
>>> Is there anything dangerous about this?
>>> class ItemList(ListView):
>>> model = Item
>>> def post(self, request, *args, **kwargs):
>>> self.request.GET = self.request.POST
>>> return super().get(request, *args, **kwargs)
>>>
>>> I want to use this to accept filtering parameters from a form in a list 
>>> view template. This ListView also has a get_queryset which returns a 
>>> filtered query based on the parameters 
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/aa7a1392-e388-4727-b412-bd1329daa6c4n%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9e6d1ed0-0061-4e88-a715-c677d300461dn%40googlegroups.com.


Permissions Model Inefficiency Killing DB

2021-11-24 Thread Ryan Skadberg
Hi All -

  Running Django 2.2.24 (Yes, I know, we are working on moving to 3.2)

  I've noticed some stalls in startup and finally have tracked it down.  It 
appears when permissions are imported, it checks EVERY user for 
permissions, NOT just the ones in the user_user_permissions table.  When 
you have 30k users in your DB this causes at least 60k SQL calls on startup.

They all look something like this:

2021-11-24 19:04:46.725 UTC [39] LOG:  duration: 0.344 ms  statement: 
SELECT "auth_group"."id", "auth_group"."name" FROM "auth_group" INNER JOIN 
"user_groups" ON ("auth_group"."id" = "user_groups"."group_id") WHERE 
"user_groups"."customuser_id" = 27345
2021-11-24 19:04:46.728 UTC [39] LOG:  duration: 0.379 ms  statement: 
SELECT "auth_permission"."id", "auth_permission"."name", 
"auth_permission"."content_type_id", "auth_permission"."codename" FROM 
"auth_permission" INNER JOIN "user_user_permissions" ON 
("auth_permission"."id" = "user_user_permissions"."permission_id") INNER 
JOIN "django_content_type" ON ("auth_permission"."content_type_id" = 
"django_content_type"."id") WHERE "user_user_permissions"."customuser_id" = 
27345 ORDER BY "django_content_type"."app_label" ASC, 
"django_content_type"."model" ASC, "auth_permission"."codename" ASC

 I have 677 rows in user_user_permissions with a minimum customuser_id of 0 
and a max of 27346.  When I start up my tests, instead of looking at the 
677 users that have permissions in the user_user_permissions table, it 
checks all 27346.  As there is nothing in the table for them, this is super 
super inefficient.

It appears that the SQL is doing something like:

select id from public.user

And really should be doing something like this to minimize SQL calls:

select id from public.user where id in (select customuser_id from 
user_user_permissions);

which in my case would be 1/30th of the calls, which would be HUGE for 
startup (60k to 2k or so).

Can anyone either explain why this is happening or a way to work around it 
or if I should file a bug?

Thanks!
Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0d5aa4db-ccd7-482a-8530-1cc8d76bbcc0n%40googlegroups.com.


Re: Multiple Templates in single list view

2021-11-24 Thread Lalit Suthar
I have gone through your views and template. They are looking fine to me.
Are you getting any error?

On Wed, 24 Nov 2021 at 23:02, Lalit Suthar  wrote:

> > Anyone plz review my code i am struggling to figure out what the issue
> here is
>
> What is the issue you are trying to resolve right now?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVHOnmK%3DvUZjWrT0vjYZi-sfpUWdAxkVDCp6A8uG_foAZg%40mail.gmail.com.


Re: Multiple Templates in single list view

2021-11-24 Thread Lalit Suthar
> Anyone plz review my code i am struggling to figure out what the issue
here is

What is the issue you are trying to resolve right now?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVGfs5rLeSZb_OUfaeByYH7xV77PBzNFmC805m_xuqyT%2BA%40mail.gmail.com.


Re: def post in ListView

2021-11-24 Thread Lalit Suthar
oh my bad that is available in django rest framework only


On Wed, 24 Nov 2021 at 22:41, Lalit Suthar  wrote:

> you can use `query_params`
>
> On Wed, 24 Nov 2021 at 19:04, bnmng  wrote:
>
>> Hi everyone,
>>
>> Is there anything dangerous about this?
>> class ItemList(ListView):
>> model = Item
>> def post(self, request, *args, **kwargs):
>> self.request.GET = self.request.POST
>> return super().get(request, *args, **kwargs)
>>
>> I want to use this to accept filtering parameters from a form in a list
>> view template. This ListView also has a get_queryset which returns a
>> filtered query based on the parameters
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/aa7a1392-e388-4727-b412-bd1329daa6c4n%40googlegroups.com
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVGyGTwnd8CMqtbuF%3Da%2B43S9ar_f8%2BAQL6AC%3D%3DftaTZo8A%40mail.gmail.com.


Re: def post in ListView

2021-11-24 Thread Lalit Suthar
you can use `query_params`

On Wed, 24 Nov 2021 at 19:04, bnmng  wrote:

> Hi everyone,
>
> Is there anything dangerous about this?
> class ItemList(ListView):
> model = Item
> def post(self, request, *args, **kwargs):
> self.request.GET = self.request.POST
> return super().get(request, *args, **kwargs)
>
> I want to use this to accept filtering parameters from a form in a list
> view template. This ListView also has a get_queryset which returns a
> filtered query based on the parameters
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/aa7a1392-e388-4727-b412-bd1329daa6c4n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVF2S-b-Kst%3DRYM9Sg5G%2B2URa1J9FPyQNqd0yHPdHPHfUQ%40mail.gmail.com.


def post in ListView

2021-11-24 Thread bnmng
Hi everyone,

Is there anything dangerous about this?
class ItemList(ListView):
model = Item
def post(self, request, *args, **kwargs):
self.request.GET = self.request.POST
return super().get(request, *args, **kwargs)

I want to use this to accept filtering parameters from a form in a list 
view template. This ListView also has a get_queryset which returns a 
filtered query based on the parameters 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aa7a1392-e388-4727-b412-bd1329daa6c4n%40googlegroups.com.