Commit Graph

651 Commits

Author SHA1 Message Date
Andrew Godwin d5df7a0515 Fixed #21969: Fix behaviour of initial_data with migrated apps 2014-02-09 12:22:59 +00:00
Andrew Godwin 2085f53f56 Fixed #21968: Bad detection of old-style apps to add initial migration 2014-02-09 11:42:10 +00:00
mlavin 0ac13ecceb Remove check_migrations from the runserver command and use the new checks framework to check for unapplied migrations. Don't check for migrations if the DATABASES setting is empty. 2014-02-08 09:01:59 -05:00
Michael Manfre 3ffeb93186 Ensure cursors are closed when no longer needed.
This commit touchs various parts of the code base and test framework. Any
found usage of opening a cursor for the sake of initializing a connection
has been replaced with 'ensure_connection()'.
2014-02-02 12:47:21 -05:00
Tim Graham 2b6914049a Fixed #21849 -- Included the count of silenced system checks in output. 2014-01-28 08:31:02 -05:00
Wojciech Banaś 8f2f48ecc9 Fixed #21866 -- Replaced "COMMIT" in managmement command SQL with backend hook. 2014-01-26 12:42:41 -05:00
Aymeric Augustin f901b4d6c8 Took advantage of the new get_model API. Refs #21702. 2014-01-26 13:08:05 +01:00
Aymeric Augustin ee4b806a85 Fixed #21873 -- Removed duplicate import.
Thanks Sephi for the report.
2014-01-25 23:22:03 +01:00
Russell Keith-Magee d818e0c9b2 Fixed #16905 -- Added extensible checks (nee validation) framework
This is the result of Christopher Medrela's 2013 Summer of Code project.

Thanks also to Preston Holmes, Tim Graham, Anssi Kääriäinen, Florian
Apolloner, and Alex Gaynor for review notes along the way.

Also: Fixes #8579, fixes #3055, fixes #19844.
2014-01-20 10:45:21 +08:00
JustinTArthur 298a2b577f Adjusted inspectdb management command to yield PEP 8-compliant output barring Django Coding Style exceptions. 2014-01-17 18:03:16 -05:00
Marc Tamlyn ac8d0a4815 Remove unneded open(.., 'U') when on python 3.
Universal newlines is enabled by default on py3, and the usage of 'U' is
deprecated in py3.4.
2014-01-13 17:11:21 +00:00
Aymeric Augustin 0a7588dd3f Fixed #21770 -- Updated autocomplete for app-loading.
Thanks dfunckt for the report.
2014-01-12 22:29:27 +01:00
Aymeric Augustin d562527a16 Fixed #21477 -- Renamed db to using in pre/post_migrate signals. 2014-01-12 22:24:33 +01:00
Aymeric Augustin 2dcde523ab Avoided catching ImproperlyConfigured on django.setup().
Fixed #21737. Thanks Florian for the report.

Also removed redundant imports in that file.
2014-01-06 23:01:29 +01:00
Claude Paroz aaf5b3e7aa Moved django.setup() to ManagementUtility
In get_commands, setup() might already have been called, for example
when the management command is called through call_command. Moving
setup() to ManagementUtility so as it is only called when the command
is run from command line.
2014-01-02 20:47:40 +01:00
Aymeric Augustin 30a42a4fc3 Adjusted previous commit for Python 3. 2014-01-01 19:12:46 +01:00
Aymeric Augustin 0ce945a671 Fixed #21018 -- Reversed precedence order for management commands. 2014-01-01 18:11:15 +01:00
Aymeric Augustin f17d00278e Wiped get_commands() cache when INSTALLED_APPS changes.
Refs #21018, #21688.
2014-01-01 18:11:09 +01:00
Aymeric Augustin a95f74e707 Oops. 2013-12-31 13:16:51 +01:00
Aymeric Augustin 6b172a6d6d Called django.setup() explicitly in management commands.
This avoids duplicating code.
2013-12-31 13:11:05 +01:00
Aymeric Augustin bfcc686d22 Removed the only_with_models_module argument of 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.
2013-12-30 23:59:34 +01:00
Aymeric Augustin 1c242a297b Merged Apps.populate_apps() and populate_models().
After the recent series of refactorings, there's no reason to keep
two distinct methods.

Refs #21681.
2013-12-30 23:18:22 +01:00
Aymeric Augustin 0d2c8ff2be Populated the app registry earlier at startup.
Refs #1796, #21676.
2013-12-30 22:11:16 +01:00
Aymeric Augustin 5892a83b18 Stopped calling get_models() for a side effect. 2013-12-29 21:48:58 +01:00
Aymeric Augustin e5bcd1d455 Changed get_validation_errors to use an app config. 2013-12-29 21:48:58 +01:00
Aymeric Augustin 856aaaf2b1 Changed get_migratable_models to use an app config. 2013-12-29 21:25:28 +01:00
Aymeric Augustin 1d4bcb86ea Changed sql_* to use an app config instead of a models module. 2013-12-29 21:25:28 +01:00
Aymeric Augustin 368d90e261 Removed unused import. 2013-12-29 20:45:34 +01:00
Aymeric Augustin 7b88a96553 Added AppConfig.get_models(). 2013-12-29 20:31:59 +01:00
Aymeric Augustin 00110904ac Refactored the migration signals to use app configs.
De-aliased pre/post_syncdb to pre/post_migrate to increase
backwards-compatibility.
2013-12-29 17:53:42 +01:00
Aymeric Augustin ba7206cd81 Changed get_model to raise an exception on errors.
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-28 20:53:00 +01:00
Aymeric Augustin c81fae6b95 Used app_label instead of appname.
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-28 09:53:02 +01:00
Aymeric Augustin a7add2f296 Migrated built-in AppCommands to use handle_app_config. 2013-12-28 09:43:06 +01:00
Aymeric Augustin bb8ec71f61 Updated the AppCommand API to support apps without a models module. 2013-12-28 09:42:59 +01:00
Aymeric Augustin efddae252c Refactored dumpdata with app configs instead of models modules. 2013-12-27 21:25:35 +01:00
Aymeric Augustin ce1bc2c94b Made the AppConfig API marginally more consistent.
Eliminated the app_ prefix that was more confusing than useful.
2013-12-26 19:25:09 +01:00
Aymeric Augustin 1716b7ce5a Renamed AppCache to Apps.
Also renamed app_cache to apps and "app cache" to "app registry".

Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
2013-12-24 12:25:17 +01:00
Aymeric Augustin 2fef9e5375 Moved apps back in the toplevel django namespace.
Reverted 4a56a93cc4.
2013-12-22 11:39:55 +01:00
Aymeric Augustin 65cd74be8e Stopped iterating on INSTALLED_APPS.
Used the app cache's get_app_configs() method instead.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 4582993302 Populated models only when necessary in get_app_config[s].
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-22 11:39:18 +01:00
Aymeric Augustin 4a56a93cc4 Moved the new app cache inside core. 2013-12-17 10:17:46 +01:00
Aymeric Augustin 5ba743e262 Made it possible to create apps without a models module.
This commit reverts f44c4a5d0f and 39bbd165.

django.test.simple will be updated in a separate commit as it requires
invasive changes.
2013-12-17 10:17:45 +01:00
Aymeric Augustin 69039becde Deprecated get_app(). 2013-12-17 10:17:45 +01:00
Aymeric Augustin 2732edc5f2 Deprecated get_apps(). 2013-12-17 10:17:45 +01:00
Aymeric Augustin 259cd3cd41 Deprecated get_app_package, get_app_path and get_app_paths. 2013-12-17 10:17:45 +01:00
Aymeric Augustin 2c9e84af4a Removed unused attribute app_errors of the app cache.
get_app_errors() always returned an empty dictionary; this behavior is
preserved in django.db.models.loading until that module is deprecated.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 8662654d6d Removed module-level functions for the app cache.
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-17 10:17:44 +01:00
Aymeric Augustin 860c2c8bc5 Moved django.db.models.loading to django.apps.cache.
This commit doesn't contain any code changes; it's purely a refactoring.
2013-12-17 10:17:43 +01:00
Loic Bistuer 6685713869 Fixed E127 pep8 warnings. 2013-12-14 11:59:15 -05:00
Loic Bistuer a2814846ca Fixed E124 pep8 warnings. 2013-12-10 15:12:48 -05:00