Re: Improve queries on django admin

2016-07-21 Thread Lucas Magnum
You can use `list_select_related` for Django Admin too.




[]'s

Lucas Magnum.

2016-07-21 15:52 GMT-03:00 Rael Max :

> Hi everyone,
>
> I'm working in a project with a large mysql database and i've faced with
> problems generated on django admin list. Basically, the query executed to
> retrieve a list of items from a model uses a SQL SELECT passing a list of
> all attributes of model, but usually we only use a small set of them on
> *list_display* attribute.
>
> I solved this problem overriding the *queryset* method of *ModelAdmin*
> and using the method only of *QuerySet* using the fields listed on
> *list_display* attribute of *ModelAdmin*. With the limit of columns
> retrieved this queries should to consume less memory to be executed.
>
> Searching about this here and on django issue tracker i've not found
> nothing about. What you think about this optimization be the default
> behavior or use a *ModelAdmin* attribute to enable?
>
> Regards,
> Rael
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/0fab70ef-2217-4069-9f37-2ec2376626c6%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAAB7jOyvvyu_DV0iiLbyOiMTg-7UQSrVzivo3wCJmmHZYO4M8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Improve queries on django admin

2016-07-21 Thread Rael Max
Hi everyone,

I'm working in a project with a large mysql database and i've faced with 
problems generated on django admin list. Basically, the query executed to 
retrieve a list of items from a model uses a SQL SELECT passing a list of 
all attributes of model, but usually we only use a small set of them on 
*list_display* attribute.

I solved this problem overriding the *queryset* method of *ModelAdmin* and 
using the method only of *QuerySet* using the fields listed on 
*list_display* attribute of *ModelAdmin*. With the limit of columns 
retrieved this queries should to consume less memory to be executed.

Searching about this here and on django issue tracker i've not found 
nothing about. What you think about this optimization be the default 
behavior or use a *ModelAdmin* attribute to enable?

Regards,
Rael

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/0fab70ef-2217-4069-9f37-2ec2376626c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Make django.db.models.deletion.Collector public?

2016-07-21 Thread Romain Garrigues
Hi Shai,

I needed a similar feature in one of my projects.
I have started to use and try to extend the Django collector used in Admin 
deletion, and finished with something I was not really happy about...
I have then created a full collector (following all relations, foreign 
keys, manytomany, GFK, ...) named DeepCollector and that I released as 
django-deep-collector[1] package.
Some parameters allow you to collect some models, excludes other ones, ...
I actively maintain and use it on a daily basis in a big project (300+ 
tables) to download some production data and load it in my local 
environment.

I hope this can help!

Romain.

[1]https://github.com/iwoca/django-deep-collector

Le lundi 18 juillet 2016 15:00:59 UTC+2, Shai Berger a écrit :
>
> Hi, 
>
> We're implementing a feature where we need to access all the dependent 
> objects 
> for a given set of objects -- much like the Admin's deletion does. I note 
> that 
> we are not the first with this need, and I bring the SO question[1] as 
> evidence. As you can see in that question, it turns out that already in 
> Django, there is more than one such collector -- the one[2] used in 
> delete() 
> is not exactly suitable for use in the Admin[3]. 
>
> Shouldn't we make the collector class -- or, at least, some API to achieve 
> the 
> same goal -- public? 
>
> Shai 
>
> [1]http://stackoverflow.com/questions/12158714/ 
> [2]
> https://github.com/django/django/blob/c339a5a6/django/db/models/deletion.py#L64
>  
> [3]
> https://github.com/django/django/blob/f6681393/django/contrib/admin/utils.py#L176
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/c3cc356d-32ce-430c-a788-075233aa69b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.