Commit Graph

277 Commits

Author SHA1 Message Date
Daniel Pyrathon fb48eb0581 Fixed #12663 -- Formalized the Model._meta API for retrieving fields.
Thanks to Russell Keith-Magee for mentoring this Google Summer of
Code 2014 project and everyone else who helped with the patch!
2015-01-06 19:25:12 -05:00
Daniel Pyrathon 8958170755 Fixed #9104 -- Moved FieldDoesNotExist to core.exceptions 2015-01-02 10:46:04 -05:00
Claude Paroz 108b8bf852 Fixed #24007 -- Ensure apps registry's ready before unpickling models
This prevents AppRegistryNotReady errors when unpickling Django
models from an external script.
2014-12-17 18:33:32 +01:00
Markus Holtermann e37ab311fc Changed internal storing of abstract and concrete managers to be in a single list.
This commit prepares the internal manager layout to be serialized by
migrations; refs #23822.
2014-12-15 08:32:47 -05:00
Anssi Kääriäinen c7175fcdfe Fixed #901 -- Added Model.refresh_from_db() method
Thanks to github aliases dbrgn, carljm, slurms, dfunckt, and timgraham
for reviews.
2014-11-28 06:54:00 -05:00
Carl Meyer e7b9a58b08 Fixed #21794 -- Removed deprecation warning for abstract models outside an app. 2014-11-19 15:56:04 -07:00
Karen Tracey dec93d8991 Fixed #21612 -- Made QuerySet.update() respect to_field 2014-11-16 15:44:13 +01:00
Jozef Knaperek c56c42b5c0 Fixed #22967 -- Made Model._do_update consistent
Made _do_update behave more strictly according to its docs,
including a corner case when specific concurent updates are
executed and select_on_save is set.
2014-11-12 12:53:30 +02:00
Tim Graham c32bc1a7a7 Fixed #11775 -- Made ABSOLUTE_URL_OVERRIDES work with models that don't define get_absolute_url().
Thanks jukvalim for the report and initial patch,
and Preston Timmons for review.
2014-09-09 11:05:31 -04:00
Tim Graham 1101467ce0 Limited lines to 119 characters in django/
refs #23395.
2014-09-05 09:22:16 -04:00
Shai Berger dd9b3312d0 Fixed name of database connection feature 2014-07-14 19:23:57 +03:00
Anssi Kääriäinen 0b6f05ede6 Fixed #19501 -- added Model.from_db() method
The Model.from_db() is intended to be used in cases where customization
of model loading is needed. Reasons can be performance, or adding custom
behavior to the model (for example "dirty field tracking" to issue
automatic update_fields when saving models).

A big thank you to Tim Graham for the review!
2014-07-01 16:31:01 +03:00
Anubhav Joshi 1c50d6ae2b Fixed problem introduced with #refs 13711. 2014-06-23 19:36:40 +03:00
Anubhav Joshi 91f1b6dcdc Fixed #13711 -- Model check added to ensure that auto-generated column name is within limits of the database.
Thanks russellm for report and Tim Graham for review.
2014-06-17 16:16:02 -04:00
Anubhav Joshi 42736ac8e8 Fixed #21430 -- Added a RuntimeWarning when unpickling Models and QuerySets from a different Django version.
Thanks FunkyBob for the suggestion, prasoon2211 for the initial patch,
and akaariai, loic, and charettes for helping in shaping the patch.
2014-06-11 10:03:34 -04:00
Craig de Stigter ce993efda8 Fixed #22690 -- Added a check for proxy models containing fields.
Removed the FieldError raised by ModelBase.__new__ in this case.
2014-06-02 09:32:38 -04:00
Vincent-Vega d04e730224 Fixed #22711 -- Adjusted ordering checks to allow implicit relation fields.
refs #19195.
2014-06-01 15:36:25 -04:00
Tim Graham 1efb2e73bf Fixed typo. 2014-05-16 16:39:12 -04:00
Vlad Starostin 1be03aff5c Fixed #18389 -- Fixed the way contribute_to_class is called
Now this method is only called only if the object is an instance.
This allows to have field classes as model class attributes.
2014-05-16 10:40:07 -04:00
Yehonatan Daniv e2e4cdba11 Fixed #22539 -- Copied exclude argument in Model.full_clean() to prevent side effects. 2014-05-01 09:28:11 -04:00
Simon Charette a2340ac6d6 Use the new implementation of `six.with_metaclass`.
No more `NewBase` horrors.

Thanks to bendavis78 for his work on merging this into six.
2014-04-29 09:43:08 -04:00
Aymeric Augustin 428c0bbe1b Appeased flake8 2.1.0. 2014-04-21 12:27:34 +02:00
Marc Egli 0bcc92c691 Fixed #22356 -- Added a check to make sure unique_together fields are local. 2014-04-14 16:49:40 -04:00
Claude Paroz 0a65da941c Fixed #22236 -- Removed inappropriate usage of signals
Thanks Aymeric Augustin for the report and Tim Graham for the review.
2014-04-05 21:00:31 +02:00
Aymeric Augustin 0f9560855e Removed legacy transaction management per the deprecation timeline. 2014-03-21 21:06:50 +01:00
Claude Paroz 210d0489c5 Fixed #21188 -- Introduced subclasses for to-be-removed-in-django-XX warnings
Thanks Anssi Kääriäinen for the idea and Simon Charette for the
review.
2014-03-08 09:57:40 +01:00
Russell Keith-Magee bc4dc6e99c Edited model check messages for grammar and consistency. 2014-03-03 15:35:42 +08:00
Christopher Medrela ee9fcb1672 Fixed #17673 -- Forbid field shadowing.
Thanks Anssi Kääriäinen for the suggestion.
2014-02-10 10:04:19 -05:00
Loic Bistuer 8847a0c601 Fixed #16192 -- Made unique error messages in ModelForm customizable.
Overriding the error messages now works for both unique fields, unique_together
and unique_for_date.

This patch changed the overriding logic to allow customizing NON_FIELD_ERRORS
since previously only fields' errors were customizable.

Refs #20199.

Thanks leahculver for the suggestion.
2014-02-08 04:59:09 -05:00
Aymeric Augustin 4f03b718f7 Fixed #21877 -- Renamed django.apps.base to config. 2014-01-26 13:17:03 +01:00
Aymeric Augustin f901b4d6c8 Took advantage of the new get_model API. Refs #21702. 2014-01-26 13:08:05 +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
Andrew Godwin 3f1a008266 Fixed #21664: Multi-table inheritance was duplicating _ptr fields 2014-01-19 18:35:49 +00:00
Aymeric Augustin 2f65b8e14c Fixed #21794 -- Adjusted warning for abstract models.
As far as I can tell, they don't need an app_label.

Thanks Simon Charette for the report and the review.
2014-01-18 18:23:13 +01:00
Aymeric Augustin 3326a412cc Deprecated importing a model before loading its application.
Refs #21719, #21680.
2014-01-10 23:43:10 +01:00
Aymeric Augustin f630373b92 Fixed #21711 -- Enforced unicity of model names. 2014-01-05 20:52:53 +01:00
Aymeric Augustin c40209dcc0 Made it possible to change an application's label in its configuration.
Fixed #21683.
2013-12-31 17:30:58 +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 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 17c66e6fe7 Renamed has_model to get_registered_models.
That matches its return type better.
2013-12-22 17:08: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 70c9654d45 Renamed registered_model to has_model.
This avoids possible confusion with register_model.

Thanks Marc Tamlyn for the suggestion.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 86804ab063 Terminated AppCache._populate() with extreme prejudice.
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-22 11:39:17 +01:00
Aymeric Augustin 742ed9878e Refactored registration of models.
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-22 11:39:17 +01:00
Aymeric Augustin 4a56a93cc4 Moved the new app cache inside core. 2013-12-17 10:17:46 +01:00
Aymeric Augustin ebda5800ae Simplified register_models.
Since it's never called with more than one model at a time the current
signature is needlessly complicated.
2013-12-17 10:17:45 +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 f563c339ca Fixed #20867 -- Added the Form.add_error() method.
Refs #20199 #16986.

Thanks @akaariai, @bmispelon, @mjtamlyn, @timgraham for the reviews.
2013-11-30 01:00:53 +07:00