Django

Code

Changeset 5259

Show
Ignore:
Timestamp:
05/16/07 11:30:51 (1 year ago)
Author:
bouldersprinters
Message:

boulder-oracle-sprint: Merged to [5258]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/boulder-oracle-sprint/docs/db-api.txt

    r5128 r5259  
    144144 
    145145    * If the object's primary key attribute is set to a value that evaluates to 
    146       ``True`` (i.e., a value other than ``None`` or the empty string), Django  
    147       executes a ``SELECT`` query to determine whether a record with the given  
     146      ``True`` (i.e., a value other than ``None`` or the empty string), Django 
     147      executes a ``SELECT`` query to determine whether a record with the given 
    148148      primary key already exists. 
    149149    * If the record with the given primary key does already exist, Django 
     
    526526    >>> Entry.objects.filter(headline__contains='Lennon').dates('pub_date', 'day') 
    527527    [datetime.datetime(2005, 3, 20)] 
    528      
     528 
    529529``none()`` 
    530530~~~~~~~~~~ 
     
    532532**New in Django development version** 
    533533 
    534 Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to  
     534Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to 
    535535an empty list. This can be used in cases where you know that you should 
    536536return an empty result set and your caller is expecting a ``QuerySet`` 
     
    538538 
    539539Examples:: 
    540      
     540 
    541541    >>> Entry.objects.none() 
    542542    [] 
     
    611611 
    612612The ``depth`` argument is new in the Django development version. 
    613      
     613 
    614614``extra(select=None, where=None, params=None, tables=None)`` 
    615615~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    11371137~~~~~~ 
    11381138 
    1139 Takes either ``True`` or ``False``, which correspond to SQL queries of  
     1139Takes either ``True`` or ``False``, which correspond to SQL queries of 
    11401140``IS NULL`` and ``IS NOT NULL``, respectively. 
    11411141 
     
    11501150.. admonition:: ``__isnull=True`` vs ``__exact=None`` 
    11511151 
    1152     There is an important difference between ``__isnull=True`` and  
     1152    There is an important difference between ``__isnull=True`` and 
    11531153    ``__exact=None``. ``__exact=None`` will *always* return an empty result 
    1154     set, because SQL requires that no value is equal to ``NULL``.  
    1155     ``__isnull`` determines if the field is currently holding the value  
     1154    set, because SQL requires that no value is equal to ``NULL``. 
     1155    ``__isnull`` determines if the field is currently holding the value 
    11561156    of ``NULL`` without performing a comparison. 
    11571157 
     
    11821182 
    11831183For convenience, Django provides a ``pk`` lookup type, which stands for 
    1184 "primary_key".  
     1184"primary_key". 
    11851185 
    11861186In the example ``Blog`` model, the primary key is the ``id`` field, so these 
     
    11911191    Blog.objects.get(pk=14) # pk implies id__exact 
    11921192 
    1193 The use of ``pk`` isn't limited to ``__exact`` queries -- any query term  
     1193The use of ``pk`` isn't limited to ``__exact`` queries -- any query term 
    11941194can be combined with ``pk`` to perform a query on the primary key of a model:: 
    11951195 
     
    11971197    Blog.objects.filter(pk__in=[1,4,7]) 
    11981198    # Get all blog entries with id > 14 
    1199     Blog.objects.filter(pk__gt=14)  
    1200      
     1199    Blog.objects.filter(pk__gt=14) 
     1200 
    12011201``pk`` lookups also work across joins. For example, these three statements are 
    12021202equivalent:: 
     
    17551755 
    17561756One common idiom to use ``get()`` and raise ``Http404`` if the 
    1757 object doesn't exist. This idiom is captured by ``get_object_or_404()``.  
    1758 This function takes a Django model as its first argument and an  
    1759 arbitrary number of keyword arguments, which it passes to the manager's  
     1757object doesn't exist. This idiom is captured by ``get_object_or_404()``. 
     1758This function takes a Django model as its first argument and an 
     1759arbitrary number of keyword arguments, which it passes to the manager's 
    17601760``get()`` function. It raises ``Http404`` if the object doesn't 
    1761 exist. For example::  
    1762      
     1761exist. For example:: 
     1762 
    17631763    # Get the Entry with a primary key of 3 
    17641764    e = get_object_or_404(Entry, pk=3) 
    17651765 
    1766 When you provide a model to this shortcut function, the default manager  
    1767 is used to execute the underlying ``get()`` query. If you don't want to  
    1768 use the default manager, or you want to search a list of related objects,  
    1769 you can provide ``get_object_or_404()`` with a manager object, instead.  
     1766When you provide a model to this shortcut function, the default manager 
     1767is used to execute the underlying ``get()`` query. If you don't want to 
     1768use the default manager, or if you want to search a list of related objects, 
     1769you can provide ``get_object_or_404()`` with a manager object instead. 
    17701770For example:: 
    17711771 
     
    17801780----------------- 
    17811781 
    1782 ``get_list_or_404`` behaves the same was as ``get_object_or_404()``  
    1783 -- except the it uses using ``filter()`` instead of ``get()``. It raises  
     1782``get_list_or_404`` behaves the same way as ``get_object_or_404()`` 
     1783-- except that it uses ``filter()`` instead of ``get()``. It raises 
    17841784``Http404`` if the list is empty. 
    17851785 
  • django/branches/boulder-oracle-sprint/docs/model-api.txt

    r5174 r5259  
    17601760    <a href="{{ object.get_absolute_url }}">{{ object.name }}</a> 
    17611761 
     1762.. note:: 
     1763    The string you return from ``get_absolute_url()`` must be use only ASCII 
     1764    characters (required by the URI spec, `RFC 2396`_) that has been 
     1765    URL-encoded, if necessary. Code and templates using ``get_absolute_url()`` 
     1766    should be able to use the result directly without needing to do any 
     1767    further processing. 
     1768 
     1769.. _RFC 2396: http://www.ietf.org/rfc/rfc2396.txt 
     1770 
    17621771The ``permalink`` decorator 
    17631772~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • django/branches/boulder-oracle-sprint/docs/syndication_feeds.txt

    r5148 r5259  
    147147      passing it a single parameter, ``item``, which is the object itself. 
    148148      Both ``get_absolute_url()`` and ``item_link()`` should return the item's 
    149       URL as a normal Python string. 
     149      URL as a normal Python string. As with ``get_absolute_url()``, the 
     150      result of ``item_link()`` will be included directly in the URL, so you 
     151      are responsible for doing all necessary URL quoting and conversion to 
     152      ASCII inside the method itself. 
    150153 
    151154    * For the LatestEntries example above, we could have very simple feed templates: