Re: Add warning or prohibit module level queries?

2021-09-27 Thread laym...@gmail.com
+1, I've had people raising issues that were caused by this. They were using a query to provide a model field's default value. On Sunday, 26 September 2021 at 02:06:21 UTC+7 Adam Johnson wrote: > I noticed I've continued to encounter this problem in code review > relatively frequently, so I

Re: Add warning or prohibit module level queries?

2021-09-25 Thread 'Adam Johnson' via Django developers (Contributions to Django itself)
I noticed I've continued to encounter this problem in code review relatively frequently, so I made a ticket: https://groups.google.com/g/django-developers/c/7JwWatLfP44/ . Tim then pointed me back to this discussion. I'm happy to implement Tim's suggestion of a RuntimeWarning followed by

Re: Add warning or prohibit module level queries?

2016-02-25 Thread Curtis Maloney
+1 At the very least we need to provide better feedback or errors to help isolate _where_ this is happening. I've helped quite a number of people on IRC with this problem... firstly, people aren't understanding _what_ the problem is, but also discerning where it's happening is often quite

Re: Add warning or prohibit module level queries?

2016-02-25 Thread Aymeric Augustin
Hello, To the best of my knowledge, in Django 1.10, the window for such problematic database queries will shrink to the interval between the moment `apps.models_ready` becomes `True` and the moment `apps.ready` becomes `True`. That’s when AppConfig.ready() methods execute. In Django 1.9, if a

Add warning or prohibit module level queries?

2016-02-25 Thread Tim Graham
Simon proposed [0]: "I wonder if we should prevent django.db from executing queries until django.apps.apps.ready or at least issue a RuntimeWarning. We would have to go through deprecation but I'm pretty sure this would uncover a lot of existing application bugs and prevent future ones. This