| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
unhandled lazy ops error.
|
|
|
|
|
|
|
|
|
|
| |
Moved the lookup in Field.swappable_setting to Apps, and added
an lru_cache to cache the results.
Refs #24743
Thanks Marten Kenbeek for the initial work on the patch. Thanks Aymeric
Augustin and Tim Graham for the review.
|
| |
|
|
|
|
| |
message on fully-qualified package names.
|
|
|
|
|
|
|
| |
This adds a new method, Apps.lazy_model_operation(), and a helper function,
lazy_related_operation(), which together supersede add_lazy_relation() and
make lazy model operations the responsibility of the App registry. This
system no longer uses the class_prepared signal.
|
|
|
|
|
|
|
|
| |
Set apps.ready to False when rendering multiple models. This prevents
that the cache on Model._meta is expired on all models after each time a
single model is rendered. Prevented that Apps.clear_cache() refills the
cache on Apps.get_models(), so that the wrong value cannot be cached
when cloning a StateApps.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
retrieving fields.
Thanks to Russell Keith-Magee for mentoring this Google Summer of
Code 2014 project and everyone else who helped with the patch!
|
|
|
|
| |
Thanks dfunckt and Tim Graham.
|
|
|
|
|
|
|
|
|
|
|
| |
is reloaded.
Previously a RuntimeError was raised every time two models clashed
in the app registry. This prevented reloading a module in a REPL;
while it's not recommended to do so, we decided not to forbid this
use-case by turning the error into a warning.
Thanks @dfunckt and Sergey Pashinin for the initial patches.
|
|
|
|
|
|
|
| |
This reverts commit 6fa9fa91a5fcb228b3c385b35a2018b3821a447a.
Aymeric: "I chose not to talk about django.setup() here on purpose.
This will hardly always be the correct solution."
|
| |
|
|
|
|
|
| |
Accounted for the three stages of population: app configs, models,
ready() methods of app configs.
|
|
|
|
|
|
| |
translation setup
Thanks Tim Graham and Aymeric Augustin for the review.
|
|
|
|
|
|
|
| |
to-be-removed-in-django-XX warnings
Thanks Anssi Kääriäinen for the idea and Simon Charette for the
review.
|
| |
|
|
|
|
| |
Also added tests for get_model.
|
|
|
|
|
|
| |
custom label.
Thanks Aymeric for design discussion.
|
|
|
|
|
|
|
|
| |
Since the app registry is always populated before the first request is
processed, the situation described in #18251 for the old app cache
cannot happen any more.
Refs #18251, #21628.
|
| |
|
| |
|
|
|
|
|
|
| |
Thanks Jannis and Marc for the feedback.
Fixed #21717.
|
|
|
|
| |
Fixed #21679.
|
|
|
|
|
|
| |
configuration.
Fixed #21683.
|
|
|
|
|
|
|
|
|
| |
app registry.
This check will miss duplicates until the check for duplicate labels is
added.
Refs #21679.
|
|
|
|
| |
Fixed #21715.
|
|
|
|
|
|
|
|
|
| |
get_model[s].
Now that the refactorings are complete, it isn't particularly useful any
more, nor very well named. Let's keep the API as simple as possible.
Fixed #21689.
|
|
|
|
|
|
|
| |
After the recent series of refactorings, there's no reason to keep
two distinct methods.
Refs #21681.
|
|
|
|
|
|
|
|
|
|
| |
To the best of my understanding, since populate_models() is now called
as soon as Django starts, it cannot be called while a models module is
being imported, and that removes the need for postponing.
(If hell breaks loose we'll revert this commit.)
Refs #21681.
|
|
|
|
|
|
|
| |
Since it triggers imports, it shouldn't be done lightly.
This commit adds a public API for doing it explicitly, django.setup(),
and does it automatically when using manage.py and wsgi.py.
|
| |
|
| |
|
| |
|
|
|
|
| |
Use app_config.get_models() instead.
|
| |
|
| |
|
|
|
|
| |
This avoid leaking implementation details to tests that swap models.
|
|
|
|
| |
Refs #15903, #15866, #15850.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Returning None on errors required unpythonic error checking and was
inconsistent with get_app_config.
get_model was a private API until the previous commit, but given that it
was certainly used in third party software, the change is explained in
the release notes.
Applied the same change to get_registered_model, which is a new private
API introduced during the recent refactoring.
|
|
|
|
| |
Documented them as public APIs.
|
|
|
|
|
|
|
|
| |
This removes the gap between the master app registry and ad-hoc app
registries created by the migration framework, specifically in terms
of behavior of the get_model[s] methods.
This commit contains a stealth feature that I'd rather not describe.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
register_model is called exactly once in the entire Django code base, at the
bottom of ModelBase.__new__:
new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
ModelBase.__new__ exits prematurely 120 lines earlier (sigh) if a model with
the same name is already registered:
if new_class._meta.apps.get_registered_model(new_class._meta.app_label, name):
return
(This isn't the exact code, but it's equivalent.)
apps.register_model and apps.get_registered_model are essentially a setter and
a getter for apps.all_models, and apps.register_model is the only setter. As a
consequence, new_class._meta.apps.all_models cannot change in-between.
Considering that name == new_class.__name__, we can conclude that
register_model(app_label, model) is always called with such arguments that
get_registered_model(app_label, model.__name__) returns None.
Considering that model._meta.model_name == model.__name__.lower(), and looking
at the implementation of register_model and get_registered_model, this proves
that self.all_models[app_label] doesn't contain model._meta.model_name in
register_model, allowing us to simplify the implementation.
|
|
|
|
| |
The u prefix looks bad on Python 2.
|
|
|
|
|
|
| |
Previously the _apps/models_loaded flags could remain set to False if
set_installed_apps exited with an exception, which is going to happen as
soon as we add tests for invalid values of INSTALLED_APPS.
|
| |
|
| |
|
| |
|
|
Also renamed app_cache to apps and "app cache" to "app registry".
Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
|