summaryrefslogtreecommitdiff
path: root/django/db/models/base.py
AgeCommit message (Collapse)Author
2010-08-09[soc2010/query-refactor] Merged up to trunk r13556, resolved merge conflictsarchive/soc2010/query-refactorAlex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13565 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-07-01[soc2010/query-refactor] Fixed a number of issues under postgresql.Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13408 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-05-11Fixed #13513 -- Ensured that queries collecting deleted objects are issued ↵Russell Keith-Magee
on the right database, especially when dealing with m2m intermediate tables. Thanks to gavoja for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13232 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-04-30Fixed #13449 -- Corrected typo in comment. Thanks stephaner.Russell Keith-Magee
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13057 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-04-21Fixed #13328 -- Ensured that querysets on models with callable defaults can ↵Russell Keith-Magee
be pickled. No, really this time. Thanks to Alex for his help brainstorming the solution. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13013 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-03-16Fixed #12881: Corrected handling of inherited unique constraints. Thanks for ↵Karen Tracey
report fgaudin. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12797 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-03-15Fixed #12953 -- Ensure that deletion cascades through generic relations. ↵Russell Keith-Magee
Also cleans up the special-casing of generic relations in the deleted object discovery process. Thanks to carljm for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12790 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-03-12Fixed #11891 -- Ensured that attributes of get_absolute_url are preserved ↵Russell Keith-Magee
through the metaclass. Thanks to nfg for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12766 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-02-26Fixed #6191, #11296 -- Modified the admin deletion confirmation page to use ↵Russell Keith-Magee
the same object collection scheme as the actual deletion. This ensures that all objects that may be deleted are actually deleted, and that cyclic display problems are avoided. Thanks to carljm for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12598 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-02-24Fixed #12152. DoesNotExist and MultipleObjectsReturned now subclass their ↵Joseph Kocherhans
parent model's exceptions. Thanks, mattmcc and Alex Gaynor. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12567 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-02-10Fixed #12647. Allow unique_together checks be specified as lists as well as ↵Joseph Kocherhans
tuples. Thanks, Honza Král. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12403 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-22Fixed #12540, #12541 -- Added database routers, allowing for configurable ↵Russell Keith-Magee
database use behavior in a multi-db setup, and improved error checking for cross-database joins. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12272 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-14Fixed #12560. Changed validate_unique to stop checking null primary key ↵Joseph Kocherhans
values. Thanks, Honza Král. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12227 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-12Fixed some bad indentationLuke Plant
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12210 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-12Fixed #12512. Changed ModelForm to stop performing model validation on ↵Joseph Kocherhans
fields that are not part of the form. Thanks, Honza Kral and Ivan Sagalaev. This reverts some admin and test changes from [12098] and also fixes #12507, #12520, #12552 and #12553. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12206 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-10Changed a whole bunch of places to raise exception instances instead of ↵Adrian Holovaty
old-style raising exception classes plus a comma. Good for the future Python 3 conversion git-svn-id: http://code.djangoproject.com/svn/django/trunk@12180 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-10Fixed #12537 -- Fixed error in Model.full_validate(). Thanks, gaussAdrian Holovaty
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12174 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-05Fixed another instance like [12099]. Thanks again, Alex Gaynor.Joseph Kocherhans
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12100 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-05Fixed a regression in validate_unique introduced in [12098]. Thanks, Alex ↵Joseph Kocherhans
Gaynor. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12099 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-05Merged soc2009/model-validation to trunk. Thanks, Honza!Joseph Kocherhans
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12098 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-12-22Fixed #1142 -- Added multiple database support.Russell Keith-Magee
This monster of a patch is the result of Alex Gaynor's 2009 Google Summer of Code project. Congratulations to Alex for a job well done. Big thanks also go to: * Justin Bronn for keeping GIS in line with the changes, * Karen Tracey and Jani Tiainen for their help testing Oracle support * Brett Hoerner, Jon Loyens, and Craig Kimmerer for their feedback. * Malcolm Treddinick for his guidance during the GSoC submission process. * Simon Willison for driving the original design process * Cal Henderson for complaining about ponies he wanted. ... and everyone else too numerous to mention that helped to bring this feature into fruition. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-12-17Fixed #11753 - Q objects with callables no longer explode on Python 2.4. ↵Jacob Kaplan-Moss
Thanks, Jeremy Dunck. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11901 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-11-11Fixed #12163 -- Corrected the unpickling of non-deferred models. Thanks to ↵Russell Keith-Magee
rfugger for the report and test case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11732 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-11-03Fixed #10109 -- Removed the use of raw SQL in many-to-many fields by ↵Russell Keith-Magee
introducing an autogenerated through model. This is the first part of Alex Gaynor's GSoC project to add Multi-db support to Django. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11710 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-11-01Fixed #12121 -- Modified __reduce__ on a model to avoid an infinite ↵Russell Keith-Magee
recursion problem that occurs on Python 2.4. Thanks to emulbreh for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11691 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-10-29Fixed #12057 -- Corrected regression of caching performance when a model ↵Russell Keith-Magee
contained a callable default. Thanks to Michael Thornhill for the excellent assistance tracking this problem. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11681 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-10-24Fixed #11402: added a `QuerySet.exists()` method. Thanks, Alex Gaynor.Jacob Kaplan-Moss
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11646 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-06-08Fixed #11194 -- Corrected loading of Proxy models from fixtures (and, by ↵Russell Keith-Magee
extension, save_base(raw=True) for Proxy models). git-svn-id: http://code.djangoproject.com/svn/django/trunk@10955 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-06-08Fixed #10672 -- Altered save_base to ensure that proxy models send a ↵Russell Keith-Magee
post_save signal. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10954 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-05-19Fixed #11116 -- Corrected the deletion of proxy objects. Thanks to Samuel ↵Russell Keith-Magee
Adam for the fix. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10824 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-05-11Fixed #10953, #10955: proxies of proxies now work correctly, though I still ↵Jacob Kaplan-Moss
don't quite understand why you'd want to do such a thing. Thanks, Armin Ronacher. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10738 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-04-04Fixed #10695 -- Fixed implementation of deferred attribute retrieval.Malcolm Tredinnick
The original implementation had a few silly bugs in it that meant that data was not being used only on the instance of the class that it was appropriate for (one of the traps when using class-level things). No more! Thanks to Justin Bronn and Alex Gaynor for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10382 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-22Fixed deferred loading of fields with default values.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10113 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-20Fixed #2698 -- Fixed deleting in the presence of custom managers.Malcolm Tredinnick
A custom manager on a related object that filtered away objects would prevent those objects being deleted via the relation. This is now fixed. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10104 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-20Fixed #10547 -- Worked around some odd behaviour in Python 2.3 and 2.4.Malcolm Tredinnick
Calling the super() version of __reduce__ in Model.__reduce__ led to infinite loops in Python prior to 2.5. We don't do that any longer. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10099 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-19Fixed #5420 -- Added support for delayed loading of model fields.Malcolm Tredinnick
In extreme cases, some fields are expensive to load from the database (e.g. GIS fields requiring conversion, or large text fields). This commit adds defer() and only() methods to querysets that allow the caller to specify which fields should not be loaded unless they are accessed. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10090 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-18Fixed #10356 -- Added pure-Python inheritance for models (a.k.a proxy models).Malcolm Tredinnick
Large portions of this are needed for #5420, so I implemented it fully. Thanks to Ryan Kelly for an initial patch to get this started. Refs #5420. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10083 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-15Use plain model.Manager, or suitable proxy, for model saving.Malcolm Tredinnick
We can't use the default manager in Model.save_base(), since we need to retrieve existing objects which might be filtered out by that manager. We now always use a plain Manager instance at that point (or something that can replace it, such as a GeoManager), making all existing rows in the database visible to the saving code. The logic for detecting a "suitable replacement" plain base is the same as for related fields: if the use_for_related_fields is set on the manager subclass, we can use it. The general requirement here is that we want a base class that returns the appropriate QuerySet subclass, but does not restrict the rows returned. Fixed #8990, #9527. Refs #2698 (which is not fixed by this change, but it's the first part of a larger change to fix that bug.) git-svn-id: http://code.djangoproject.com/svn/django/trunk@10056 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-10Fixed #10443 -- Fixed model attribute updating after r10003.Malcolm Tredinnick
Adding a get_db_prep_save() call to the UpdateQuery code path meant it was being called twice if you updated an existing model attribute. This change removes that double call and also makes TimeField.to_python() a little more robust for the benefit of the Oracle backend (just in case). git-svn-id: http://code.djangoproject.com/svn/django/trunk@10013 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-09Pass values through get_db_prep_save() in a QuerySet.update() call.Malcolm Tredinnick
This removes a long-standing FIXME in the update() handling and allows for greater flexibility in the values passed in. In particular, it brings updates into line with saves for django.contrib.gis fields, so fixed #10411. Thanks to Justin Bronn and Russell Keith-Magee for help with this patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10003 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-06Fixed #9649 -- Better error handling in model creation.Malcolm Tredinnick
Previously, you could explicitly assign None to a non-null ForeignKey (or other) field when creating the model (Child(parent=None), etc). We now throw an exception when you do that, which matches the behaviour when you assign None to the attribute after creation. Thanks to ales.zoulek@gmail.com and ondrej.kohout@gmail.com for some analysis of this problem. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9983 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-04Made it explicit if you accidentally override a Field from a parent model.Malcolm Tredinnick
This was always not working reliably (model initialization and serialization were two of the problems). Now, it's an explicit error. Also, documented. Fixed #10252. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9974 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-04Fixed #10406 -- Fixed some problems with model inheritance and pk fields.Malcolm Tredinnick
Manually specifying both a OneToOneField(parent_link=True) and separate a primary key field was causing invalid SQL to be generated. Thanks to Ramiro Morales for some analysis on this one. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9971 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-12-09Fixed #9775 -- Fixed an oversight from r9601 and allow direct attributeMalcolm Tredinnick
lookup in the serializable_value() method. This means that abstract parents that are multi-table children of other models(no, really!!) now work again. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9618 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-12-08The first step in fixing a group of problems related to outputting a properMalcolm Tredinnick
"value" for a field that is a relation to another model. This part adds the utility method on Model that should help in general.Also cleans up the slightly ugly mess from r8957. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9601 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-11-16Fixed #9608: Ensured a Model's default repr() is printable even if its ↵Karen Tracey
__unicode__ method raises a Unicode error. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9475 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-03Fixed #7588 -- Inherit fields from concrete ancestor classes via abstract baseMalcolm Tredinnick
classes. Based on a patch from emulbreh. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8932 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-03Fixed #8825 -- Fixed a small error model field setup (on the model class) fromMalcolm Tredinnick
r8855. Patch from Christofer Bernander. Test based on one from cgrady. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8908 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-02Fixed #8309: subclasses now inherit `GenericForeignKey` correctly. There's ↵Jacob Kaplan-Moss
also now an internal API so that other "virtual fields" like GFK can be inherited as well. Thanks, msaelices. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8855 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-02Fixed #7154 -- Inherit all model managers from abstract base classes.Malcolm Tredinnick
Also added documentation describing how manager inheritance works (and when manager aren't inherited). Based on some patches from sebastian_noack and emulbreh. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8851 bcc190cf-cafb-0310-a4f2-bffc1f526a37