summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2013-12-22Populated models only when necessary in get_app_config[s].Aymeric Augustin
Took this opportunity to change get_app[s] to only consider applications containing a model module as that seems slightly more backwards compatible. Since callers that care about models pass only_with_models_module=True, this has very few consequences. Only AppCommand needed a change.
2013-12-22Deprecated load_app().Aymeric Augustin
Adjusted several tests that used it to add apps to the app cache and then attempted to remove them by manipulating attributes directly. Also renamed invalid_models to invalid_models_tests to avoid clashing application labels between the outer and the inner invalid_models applications.
2013-12-22Added an _-prefix to pending lookups because it's transient.Aymeric Augustin
2013-12-22Terminated AppCache._populate() with extreme prejudice.Aymeric Augustin
It was called _populate() before I renamed it to populate(). Since it has been superseded by populate_models() there's no reason to keep it. Removed the can_postpone argument of load_app() as it was only used by populate(). It's a private API and there's no replacement. Simplified load_app() accordingly. Then new version behaves exactly like the old one even though it's much shorter.
2013-12-22Implemented two-stage app-cache population.Aymeric Augustin
First stage imports app modules. It doesn't catch import errors. This matches the previous behavior and keeps the code simple. Second stage import models modules. It catches import errors and retries them after walking through the entire list once. This matches the previous behavior and seems useful. populate_models() is intended to be equivalent to populate(). It isn't wired yet. That is coming in the next commit.
2013-12-22Removed the app_config.installed flag.Aymeric Augustin
Since applications that aren't installed no longer have an application configuration, it is now always True in practice. Provided an abstraction to temporarily add or remove applications as several tests messed with app_config.installed to achieve this effect. For now this API is _-prefixed because it looks dangerous.
2013-12-22Removed the only_installed argument of get_app_config[s].Aymeric Augustin
It wasn't used anywhere and couldn't be implemented any more since non-installed apps no longer have a configuration.
2013-12-22Refactored registration of models.Aymeric Augustin
Got rid of AppConfig._stub. As a side effect, app_cache.app_configs now only contains entries for applications that are in INSTALLED_APPS, which is a good thing and will allow dramatic simplifications (which I will perform in the next commit). That required adjusting all methods that iterate on app_configs without checking the "installed" flag, hence the large changes in get_model[s]. Introduced AppCache.all_models to store models: - while the app cache is being populated and a suitable app config object to register models isn't available yet; - for applications that aren't in INSTALLED_APPS since they don't have an app config any longer. Replaced get_model(seed_cache=False) by registered_model() which can be kept simple and safe to call at any time, and removed the seed_cache argument to get_model[s]. There's no replacement for that private API. Allowed non-master app caches to go through populate() as it is now safe to do so. They were introduced in 1.7 so backwards compatibility isn't a concern as long as the migrations framework keeps working.
2013-12-22Added a context manager to hold the import lock.Aymeric Augustin
2013-12-22Fixed #21643 -- repeated execution of qs with F() + timedeltaAlexey Voronov
Thanks Tim Graham for review.
2013-12-20Revert "Changed admin/templates/admin/index.html to make <caption> translatable"Aymeric Augustin
This reverts commit a25fe3b65e39ff6f59ac545d7934461be6c13612. It didn't do anything. It merely added to every PO file: msgid "%(name)s" msgstr "%(name)s" Thanks Ramiro Morales for the report at: https://groups.google.com/d/msg/Django-I18N/vc2vQzv80UQ/EuaW38V7X7sJ Conflicts: django/contrib/admin/templates/admin/index.html
2013-12-20Set stacklevel for the override_settings warning.Aymeric Augustin
Refs #19031.
2013-12-19Small flake8 fixes -- number of blank lines between top level definitionsAlex Gaynor
2013-12-20Fixed #21639 -- Implemented RenderContext.__getitem__Alex Hill
It's now consistent with RenderContext.get.
2013-12-19Fixed #21478 -- Corrected docs for when Field.db_type() is called.Anubhav Joshi
2013-12-18Fixed #21585 -- Updated some links to 3rd party database projects.Tim Graham
Thanks graeme.perrow at sap.com for the original report.
2013-12-18Fixed #21613 -- Removed a hardcoded input id from the tutorial.Tim Graham
Thanks Bruno Brouard for the report.
2013-12-18Simplied some code in django.conf.__init__.Ondrej Sika
2013-12-18Fixed #21386 -- Removed admindocs dependence on sites frameworkBouke Haarsma
* Removed ADMIN_FOR setting and warn warning * Group view functions by namespace instead of site * Added a test verifying namespaces are listed Thanks to Claude Paroz for reviewing and ideas for improvement.
2013-12-18Fixed #11629 -- Deprecated callable arguments to queryset methods.Baptiste Mispelon
Callable arguments were an untested and undocumented feature.
2013-12-18Fixed #21632 -- Docs: Removed example with callable as query parameterKevin Christopher Henry
Using callables as query parameters is undocumented and not working, so this changes an example from the ForeignKey.limit_choices_to documentation that uses it.
2013-12-18Fixed #21552 -- Allowed the use of None for the iexact lookup.Denis Moskalets
Thanks Anubhav Joshi for the documentation.
2013-12-18Refs #17413 -- Added isinstance backward compatibility on ErrorList.Loic Bistuer
2013-12-18Fixed #21625 -- incorrect documentation for DiscoverRunner.build_suiteTianyi Wang
2013-12-17Style cleanup forgotten in second previous commit.Aymeric Augustin
2013-12-17Removed forgotten reference to the borg pattern.Aymeric Augustin
2013-12-17Normalized Model._meta.installed.Aymeric Augustin
Used the information from the app cache instead of creating a duplicate based on INSTALLED_APPS. Model._meta.installed is no longer writable. It was a rather sketchy way to alter private internals anyway.
2013-12-17Deborgified the app cache.Aymeric Augustin
Improved Andrew's hack to create temporary app caches to handle migrations. Now the main app cache has a "master" flag set to True (which is a non-default keyword argument, thus unlikely to be used by mistake). Other app cache instances have "master" set to False. The only sanctioned way to access the app cache is by importing django.core.apps.app_cache. If you were instanciating an app cache and relying on the Borg pattern, you'll have to refactor your code.
2013-12-17Removed superfluous models.py files.Aymeric Augustin
Added comments in the three empty models.py files that are still needed. Adjusted the test runner to add applications corresponding to test labels to INSTALLED_APPS even when they don't have a models module.
2013-12-17Moved the new app cache inside core.Aymeric Augustin
2013-12-17Restored deprecated aliases for functions in django.db.models.Aymeric Augustin
Thanks Marc Tamlyn for the suggestion.
2013-12-17Inlined trivial method that was used only once.Aymeric Augustin
2013-12-17Fixed incorrect decrementation of nesting_level.Aymeric Augustin
Thanks Florian for catching this mistake.
2013-12-17Refactored old test runner to handle apps without a models module.Aymeric Augustin
2013-12-17Made it possible to create apps without a models module.Aymeric Augustin
This commit reverts f44c4a5d0f and 39bbd165. django.test.simple will be updated in a separate commit as it requires invasive changes.
2013-12-17Deprecated get_app().Aymeric Augustin
2013-12-17Deprecated get_apps().Aymeric Augustin
2013-12-17Removed the _-prefix for populate().Aymeric Augustin
Several parts of Django call get_apps() with a comment along this lines of "this has the side effect of calling _populate()". I fail to see how this is better than just calling populate()!
2013-12-17Simplified register_models.Aymeric Augustin
Since it's never called with more than one model at a time the current signature is needlessly complicated.
2013-12-17Simplified handling of available_apps slightly.Aymeric Augustin
It feels more natural for self.available_apps to contain app names (like INSTALLED_APPS) than app labels, and this is easy to implement now.
2013-12-17Deprecated get_app_package, get_app_path and get_app_paths.Aymeric Augustin
2013-12-17Added get_app_configs() to iterate on app_config instances.Aymeric Augustin
Refactored get_apps() to rely on that method. This commit is fully backwards-compatible.
2013-12-17Added get_app_config() to look up app configs by label.Aymeric Augustin
Refactored get_app() to rely on that method. get_app() starts by calling _populate(), which goes through INSTALLED_APPS and, for each app, imports the app module and attempts to import the models module. At this point, no further imports are necessary to return the models module for a given app. Therefore, the implementation of get_app() can be simplified and the safeguards for race conditions can be removed. Besides, the emptyOK parameter isn't used anywhere in Django. It was introduced in d6c95e93 but not actually used nor documented, and it has just been carried around since then. Since it's an obscure private API, it's acceptable to stop supporting it without a deprecation path. This branch aims at providing first-class support for applications without a models module eventually. For backwards-compatibility, get_app() still raises ImproperlyConfigured when an app isn't found, even though LookupError is technically more correct. I haven't gone as far as to preserve the exact error messages. I've adjusted a few tests instead.
2013-12-17Fleshed out AppConfig objects.Aymeric Augustin
Marginally improved creation of AppConfig stubs for non-installed apps.
2013-12-17Moved list of models inside AppConfig instances.Aymeric Augustin
This commit is a refactoring with no change of functionality, according to the following invariants: - An app_label that was in app_configs and app_models stays in app_config and has its 'installed' attribute set to True. - An app_label that was in app_models but not in app_configs is added to app_configs and has its 'installed' attribute set to True. As a consequence, all the code that iterated on app_configs is modified to check for the 'installed' attribute. Code that iterated on app_models is rewritten in terms of app_configs. Many tests that stored and restored the state of the app cache were updated. In the long term, we should reconsider the usefulness of allowing importing models from non-installed applications. This doesn't sound particularly useful, can be a trap in some circumstances, and causes significant complexity in sensitive areas of Django.
2013-12-17Removed unused attribute app_errors of the app cache.Aymeric Augustin
get_app_errors() always returned an empty dictionary; this behavior is preserved in django.db.models.loading until that module is deprecated.
2013-12-17Stored AppConfig objects instead of models modules in the app cache.Aymeric Augustin
This is a step towards allowing applications without a models module.
2013-12-17Removed module-level functions for the app cache.Aymeric Augustin
Since the original ones in django.db.models.loading were kept only for backwards compatibility, there's no need to recreate them. However, many internals of Django still relied on them. They were also imported in django.db.models. They never appear in the documentation, except a quick mention of get_models and get_app in the 1.2 release notes to document an edge case in GIS. I don't think that makes them a public API. This commit doesn't change the overall amount of global state but clarifies that it's tied to the app_cache object instead of hiding it behind half a dozen functions.
2013-12-17Removed ModelDict.Aymeric Augustin
Its only difference with OrderedDict is that it didn't deepcopy its keys. However it wasn't used anywhere with models modules as keys, only as values. So this commit doesn't result in any change in functionality.
2013-12-17Removed BaseAppCache.app_store.Aymeric Augustin
It was only storing redundant information. This is part of the effort to allow applications without a models module.