> Is it advisable to execute db queries in my AppConfig ready signal 
handler?

AppConfig.ready() is still at module-level.

> Use case: I want to add URL patterns which get collected from db rows.

It might be more appropriate to define an URL resolver (an object like 
django.conf.url)
that performs queries at resolve()/reverse() time instead.

A simpler solution could be to define a catch all view like django-cms does 
and
perform the routing inside the view.

Cheers,
Simon

Le mercredi 29 mars 2017 08:39:52 UTC-4, guettli a écrit :
>
>
>
> Am Mittwoch, 22. März 2017 19:20:43 UTC+1 schrieb Tim Graham:
>>
>> Correct, module level queries should be avoided. Django might try to add 
>> some detection to warn about or prohibit that, see 
>> https://groups.google.com/d/topic/django-developers/7JwWatLfP44/discussion
>> .
>>
>>
> I understand db queries at module-level (aka "import time") should not 
> happen.
>
> When I am allowed to do db queries.
>
> Is it advisable to execute db queries in my AppConfig ready signal handler?
>
> Use case: I want to add URL patterns which get collected from db rows.
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1687811b-b779-4031-a127-d9549bc0bdf3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to