summaryrefslogtreecommitdiff
path: root/django/db/models
AgeCommit message (Collapse)Author
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-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-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-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-10Fixed E124 pep8 warnings.Loic Bistuer
2013-12-06Corrected a flake8 issue -- this line is imported for the purpose of ↵Alex Gaynor
re-exposing the name
2013-12-06Fixed #21566 -- Fixed AttributeError when using bulk_create with ForeignObject.Roger Hu
2013-12-06Fixed #21554 -- Incorrect SQL generated when using multiple inheritance.pegler
2013-12-06Added missing deconstruct() methods.Baptiste Mispelon
2013-12-06Fixed ModelState breaking when unique_together has unhashable elements.Baptiste Mispelon
2013-12-06Fixed error in ManyToManyField.deconstruct().Baptiste Mispelon
2013-12-04Add clone() method to Field to get clean copies of it.Andrew Godwin
2013-11-30Fixed comment typos.Alex Hill
2013-11-30Fixed #20867 -- Added the Form.add_error() method.Loic Bistuer
Refs #20199 #16986. Thanks @akaariai, @bmispelon, @mjtamlyn, @timgraham for the reviews.
2013-11-29Use 'update_fields' in RelatedManager.clear() when bulk=False.Loic Bistuer
Thanks Simon Charette for the suggestion. Refs #21169.
2013-11-28Fixed E125 pep8 warningsChristopher Medrela
2013-11-27Added a bulk option to RelatedManager remove() and clear() methodsLoic Bistuer
Refs #21169
2013-11-27Used simpler queries for m2m clearing when possible.Anssi Kääriäinen
Refs #21169
2013-11-27Fixed #21169 -- Reworked RelatedManager methods use default filteringLoic Bistuer
The `remove()` and `clear()` methods of the related managers created by `ForeignKey`, `GenericForeignKey`, and `ManyToManyField` suffered from a number of issues. Some operations ran multiple data modifying queries without wrapping them in a transaction, and some operations didn't respect default filtering when it was present (i.e. when the default manager on the related model implemented a custom `get_queryset()`). Fixing the issues introduced some backward incompatible changes: - The implementation of `remove()` for `ForeignKey` related managers changed from a series of `Model.save()` calls to a single `QuerySet.update()` call. The change means that `pre_save` and `post_save` signals aren't called anymore. - The `remove()` and `clear()` methods for `GenericForeignKey` related managers now perform bulk delete so `Model.delete()` isn't called anymore. - The `remove()` and `clear()` methods for `ManyToManyField` related managers perform nested queries when filtering is involved, which may or may not be an issue depending on the database and the data itself. Refs. #3871, #21174. Thanks Anssi Kääriäinen and Tim Graham for the reviews.
2013-11-24Fixed #21391 -- Allow model signals to lazily reference their senders.Simon Charette
2013-11-20Fixed #21469 -- Allow set objects in Meta.unique_together.Baptiste Mispelon
Thanks to Tim for the review.
2013-11-15Fixed the use of the -ise suffix, where -ize is preferedAlex Gaynor
2013-11-15Fixed typo and slightly improved error message when db is missing time zone ↵Loic Bistuer
definitions. Refs #21432.
2013-11-14Fixed #21432 -- DateTimeQuery now copies tzinfo when cloning.Loic Bistuer
Thanks Enrique Martínez for the report and @bmispelon for the tests.
2013-11-13Fixed #21410 -- prefetch_related() for ForeignKeys with related_name='+'Loic Bistuer
Regression introduced by commit 9777442. Thanks to trac username troygrosfield for the report and test case.
2013-11-07Fixed #17001 -- Custom querysets for prefetch_related.Loic Bistuer
This patch introduces the Prefetch object which allows customizing prefetch operations. This enables things like filtering prefetched relations, calling select_related from a prefetched relation, or prefetching the same relation multiple times with different querysets. When a Prefetch instance specifies a to_attr argument, the result is stored in a list rather than a QuerySet. This has the fortunate consequence of being significantly faster. The preformance improvement is due to the fact that we save the costly creation of a QuerySet instance. Thanks @akaariai for the original patch and @bmispelon and @timgraham for the reviews.
2013-11-07Fixed #20600 -- ordered distinct(*fields) in subqueriesAnssi Kääriäinen
2013-11-07Removed non-necessary code in Compiler._setup_joins()Anssi Kääriäinen
2013-11-07Removed Query.setup_joins() and join() argument outer_if_first.Anssi Kääriäinen
Instead always create new joins as OUTER.
2013-11-07Fixed #21376 -- New implementation for query join promotion logicAnssi Kääriäinen
This commit introduced a new class JoinPromoter that can be used to abstract away join promotion problems for complex filter conditions. Query._add_q() and Query.combine() now use the new class. Also, added a lot of comments about why join promotion is done the way it is. Thanks to Tim Graham for original report and testing the changes, and for Loic Bistuer for review.
2013-11-03Fixed all E226 violationsAlex Gaynor