summaryrefslogtreecommitdiff
path: root/django/db
AgeCommit message (Collapse)Author
2013-12-30Removed the only_with_models_module argument of get_model[s].Aymeric Augustin
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.
2013-12-30Stopped populating the app registry as a side effect.Aymeric Augustin
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.
2013-12-30Populated Apps instances immediately by default.Aymeric Augustin
2013-12-29Changed get_migratable_models to use an app config.Aymeric Augustin
2013-12-29Replaced Options.object_name.lower() by Options.model_name.Aymeric Augustin
Thanks Simon for the suggestion. Also removed inappropriate lowercasing of app labels in migrations. Unlike model names, they are case sensitive.
2013-12-29Refactored the migration signals to use app configs.Aymeric Augustin
De-aliased pre/post_syncdb to pre/post_migrate to increase backwards-compatibility.
2013-12-28Added generation of SQLite FK DDL in initial migrations.Ramiro Morales
SQLite accepts the relevant standard SQL (although by default it doesn't enforce the constraint), and the 'traditional' creation backend helper generate it, so this allows us to: - Maintain the status quo - Improve readability of the SQL code generated for that backend. Also, we will need this for when we fix Refs #14204.
2013-12-28Removed the only_installed argument of Apps.get_models.Aymeric Augustin
Refs #15903, #15866, #15850.
2013-12-28Changed get_model to raise an exception on errors.Aymeric Augustin
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.
2013-12-28Stopped calling apps.get_model with only_installed=False.Aymeric Augustin
ContentTypes are only created for installed applications, and I could make a case for not returning a model that isn't installed any more. The check for stale ContentTypes in update_contenttypes doesn't use model_class. ModelSignal actually needs get_registered_model since the lookup happens at import time. I took this opportunity to perform a small refactoring.
2013-12-28Populated non-master app registries.Aymeric Augustin
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.
2013-12-28Implemented #10164 for new schema migration code.Ramiro Morales
Made it use 'AUTOINCREMENT' suffix for PK creation. This way it doeesn't regress when compared with the 'traditional' DB backend creation infrastructure. Refs #10164.
2013-12-28Used app_label instead of appname.Aymeric Augustin
The last component of the dotted path to the application module is consistently referenced as the application "label". For instance it's AppConfig.label. appname could be confused with AppConfig.name, which is the full dotted path.
2013-12-27Fixed #21692 -- Quote table name when creating it.Ramiro Morales
2013-12-27Created a constant for the migrations module name.Aymeric Augustin
Mostly for consistency with MODELS_MODULE_NAME; it's unlikely to change.
2013-12-26Turned apps.ready into a property. Added tests.Aymeric Augustin
2013-12-26Removed a few gratuitous lambdas.Aymeric Augustin
2013-12-25Removed redundant lineLevi Gross
2013-12-24Typo fix for exception message.Jonas Gastal
2013-12-24Renamed AppCache to Apps.Aymeric Augustin
Also renamed app_cache to apps and "app cache" to "app registry". Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
2013-12-22Renamed has_model to get_registered_models.Aymeric Augustin
That matches its return type better.
2013-12-22Moved apps back in the toplevel django namespace.Aymeric Augustin
Reverted 4a56a93cc458e9ab4dcab95d9f5067d4975dd1a2.
2013-12-22Renamed registered_model to has_model.Aymeric Augustin
This avoids possible confusion with register_model. Thanks Marc Tamlyn for the suggestion.
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-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-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-22Fixed #21643 -- repeated execution of qs with F() + timedeltaAlexey Voronov
Thanks Tim Graham for review.
2013-12-18Fixed #11629 -- Deprecated callable arguments to queryset methods.Baptiste Mispelon
Callable arguments were an untested and undocumented feature.
2013-12-18Fixed #21552 -- Allowed the use of None for the iexact lookup.Denis Moskalets
Thanks Anubhav Joshi for the documentation.
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-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-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-17Deprecated get_app_package, get_app_path and get_app_paths.Aymeric Augustin
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-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-17Moved django.db.models.loading to django.apps.cache.Aymeric Augustin
This commit doesn't contain any code changes; it's purely a refactoring.
2013-12-14Fixed E127 pep8 warnings.Loic Bistuer
2013-12-11Brought comments in sync with the code in BaseAppCache.Aymeric Augustin
2013-12-11Fixed #21563 -- Single related object descriptors should work with `hasattr`.Simon Charette
Thanks to Aymeric Augustin for the review and Trac alias monkut for the report.
2013-12-11Fix altering of SERIAL columns and InnoDB being picky about FK changesAndrew Godwin
2013-12-11Better default name for migrations we can't give nice names toAndrew Godwin
2013-12-11Change FKs when what they point to changesAndrew Godwin
2013-12-11Fix sqlmigrate's output for parametersAndrew Godwin