#26616: Documentation: Improve description of AppConfig.ready()
--------------------------------------+--------------------
Reporter: marfire | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
I find this sentence and example in the documentation a bit confusing:
You cannot import models in modules that define application
configuration classes, but you can use `get_model()` to access a model
class by name, like this:
{{{
def ready(self):
MyModel = self.get_model('MyModel')
}}}
It seems to be comparing importing ''at the module level'' with using
`get_model()` ''inside ready()''. But if I understand the '''How
applications are loaded''' section correctly, by the time `ready()` is run
the models have already been imported, and therefore it would also be fine
to do a direct import inside of `ready()`:
{{{
def ready(self):
from .models import MyModel
}}}
If that's the case then I think this sentence is confusing. If that's not
the case then I've misunderstood '''How applications are loaded''' and
perhaps it needs to be clarified.
--
Ticket URL: <https://code.djangoproject.com/ticket/26616>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.f1fd6e8701c692e934c4881015997280%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.