#24523: django.apps.registry.populate() does not handle failures in
app_config.ready()
--------------------------------------+------------------------------------
     Reporter:  kalium99              |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Core (Other)          |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by kalium99):

 Replying to [comment:10 shaib]:
 > I suspect this report to be invalid.
 >
 > Just above the quoted note in `AppConfig.ready()`'s documentation,
 there's a warning: Avoid interacting with the database. The whole point of
 this report is "ready() failed when interacting with the database".
 >

 Hi,

 I'm not sure where that above quoted text is from, and the whole point of
 this report is certainly not that ready() failed when interacting with the
 database.

 The whole point of this bug report is that the code does one or more of
 the following:

 1) Gives really unhelpful errors that do not confer the cause of the
 problem.
 2) The specific block of code in DJango does not actually work in the way
 it was intended.

 > The issue is "concealed" because the app whose `ready()` happened to
 interact with the database is `django.contrib.admin`; the interaction
 happened because, as appears in the log above,
 > {{{
 > [Sun Mar 22 23:47:26 2015] [error] [client 127.0.0.1] File
 "/home/test/apps/partners/forms.py", line 44, in PartnerSelection
 > [Sun Mar 22 23:47:26 2015] [error] [client 127.0.0.1] (p.id,
 p.company_name) for p in Partner.objects.all()])
 > }}}
 > a query is executed in the import of a forms.py file.
 >
 > The code is, of course, cut, but this looks like a "choices" argument,
 and if so, it is not only a problem because of database-interaction-
 in-`ready()`, but because it is a classic application bug -- if you add a
 Partner, it won't show in the form; the form only lets you select the
 partners that were recorded when the app started. To solve both issues,
 use a `ModelChoiceField` instead.
 >

 Both of these points are well understood and accepted. In fact in an
 earlier message I said "Technically you could say this is NOTABUG, because
 the method clearly says it is not re-entrant. " , as well as saying "This
 situation is not ideal for a couple of reasons (not in the least that the
 field is not updated until a process is recycled)."

 This ticket is about the interplay between the 'app_config'  and 'ready'
 variables, and how perhaps they don't work quite as intended, and how
 changing the error message, or the code itself, could give a better user
 experience in such circumstances.

--
Ticket URL: <https://code.djangoproject.com/ticket/24523#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.7b5dbd31379e2ac80c3f2f314d46a0a4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to