Changeset 8215 for django/branches/gis/docs/db-api.txt
- Timestamp:
- 08/05/08 12:15:33 (5 months ago)
- Files:
-
- django/branches/gis (modified) (1 prop)
- django/branches/gis/docs/db-api.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis
- Property svnmerge-integrated changed from /django/trunk:1-7978 to /django/trunk:1-8214
django/branches/gis/docs/db-api.txt
r7918 r8215 464 464 ``extra()`` calls, Django will not inspect these fragments to see if they need 465 465 to be rewritten because of changes in the merged query. So test the effects 466 carefully. Also reali se that if you are combining two ``QuerySets`` with466 carefully. Also realize that if you are combining two ``QuerySets`` with 467 467 ``|``, you cannot use ``extra(select=...)`` or ``extra(where=...)`` on *both* 468 468 ``QuerySets``. You can only use those calls on one or the other (Django will … … 1677 1677 Blog.objects.filter(entry__headline__contains='Lennon') 1678 1678 1679 If you are filtering across multiple relationships and one of the intermediate 1680 models doesn't have a value that meets the filter condition, Django will treat 1681 it as if there is an empty (all values are ``NULL``), but valid, object there. 1682 All this means is that no error will be raised. For example, in this filter:: 1683 1684 Blog.objects.filter(entry__author__name='Lennon') 1685 1686 (if there was a related ``Author`` model), if there was no ``author`` 1687 associated with an entry, it would be treated as if there was also no ``name`` 1688 attached, rather than raising an error because of the missing ``author``. 1689 Usually this is exactly what you want to have happen. The only case where it 1690 might be confusing is if you are using ``isnull``. Thus:: 1691 1692 Blog.objects.filter(entry__author__name__isnull=True) 1693 1694 will return ``Blog`` objects that have an empty ``name`` on the ``author`` and 1695 also those which have an empty ``author`` on the ``entry``. If you don't want 1696 those latter objects, you could write:: 1697 1698 Blog.objetcs.filter(entry__author__isnull=False, 1699 entry__author__name__isnull=True) 1700 1679 1701 Spanning multi-valued relationships 1680 1702 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 2219 2241 every item in a ``QuerySet`` and make sure that the ``save()`` method is 2220 2242 called on each instance, you don't need any special function to handle that. 2221 Just loop over them and call ``save()``: 2243 Just loop over them and call ``save()``:: 2222 2244 2223 2245 for item in my_queryset: … … 2281 2303 to the file, according to your ``MEDIA_ROOT`` setting. 2282 2304 2305 .. note:: 2306 It is only valid to call this method **after** saving the model when the 2307 field has been set. Prior to saving, the value returned will not contain 2308 the upload directory (the `upload_to` parameter) in the path. 2309 2283 2310 Note that ``ImageField`` is technically a subclass of ``FileField``, so every 2284 2311 model with an ``ImageField`` will also get this method. … … 2291 2318 according to your ``MEDIA_URL`` setting. If the value is blank, this method 2292 2319 returns an empty string. 2320 2321 .. note:: 2322 As with ``get_FOO_filename()``, it is only valid to call this method 2323 **after** saving the model, otherwise an incorrect result will be 2324 returned. 2293 2325 2294 2326 get_FOO_size()
