Django

Code

Show
Ignore:
Timestamp:
08/05/08 12:15:33 (4 months ago)
Author:
jbronn
Message:

gis: Merged revisions 7981-8001,8003-8011,8013-8033,8035-8036,8038-8039,8041-8063,8065-8076,8078-8139,8141-8154,8156-8214 via svnmerge from trunk.

Files:

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/add_ons.txt

    r7354 r8215  
    2424 
    2525The automatic Django administrative interface. For more information, see 
    26 `Tutorial 2`_
     26`Tutorial 2`_ and the `admin documentation`_
    2727 
    2828.. _Tutorial 2: ../tutorial02/ 
     29.. _admin documentation: ../admin/ 
    2930 
    3031Requires the auth_ and contenttypes_ contrib packages to be installed. 
     
    7778========= 
    7879 
    79 A set of high-level abstractions for Django forms (django.newforms). 
     80A set of high-level abstractions for Django forms (django.forms). 
    8081 
    8182django.contrib.formtools.preview 
  • django/branches/gis/docs/admin.txt

    r7979 r8215  
    1919======== 
    2020 
    21 There are four steps in activating the Django admin site: 
    22  
    23     1. Determine which of your application's models should be editable in the 
     21There are five steps in activating the Django admin site: 
     22 
     23    1. Add ``django.contrib.admin`` to your ``INSTALLED_APPS`` setting. 
     24 
     25    2. Determine which of your application's models should be editable in the 
    2426       admin interface. 
    2527 
    26     2. For each of those models, optionally create a ``ModelAdmin`` class that 
     28    3. For each of those models, optionally create a ``ModelAdmin`` class that 
    2729       encapsulates the customized admin functionality and options for that 
    2830       particular model. 
    2931 
    30     3. Instantiate an ``AdminSite`` and tell it about each of your models and 
     32    4. Instantiate an ``AdminSite`` and tell it about each of your models and 
    3133       ``ModelAdmin`` classes. 
    3234 
    33     4. Hook the ``AdminSite`` instance into your URLconf. 
     35    5. Hook the ``AdminSite`` instance into your URLconf. 
    3436 
    3537``ModelAdmin`` objects 
     
    4244    from django.contrib import admin 
    4345    from myproject.myapp.models import Author 
    44      
     46 
    4547    class AuthorAdmin(admin.ModelAdmin): 
    4648        pass 
     
    6769 
    6870    date_hierarchy = 'pub_date' 
     71 
     72``form`` 
     73~~~~~~~~ 
     74 
     75The default ``forms.ModelForm`` class used to generate the form on the 
     76add/change pages for models. You can easily change this to your own 
     77``ModelForm`` to override the default form behavior of the add/change pages. 
    6978 
    7079``fieldsets`` 
     
    8392 
    8493A full example, taken from the ``django.contrib.flatpages.FlatPage`` model:: 
    85      
     94 
    8695    class FlatPageAdmin(admin.ModelAdmin): 
    8796        fieldsets = ( 
     
    107116``fields`` 
    108117    A tuple of field names to display in this fieldset. This key is required. 
    109      
     118 
    110119    Example:: 
    111          
     120 
    112121        { 
    113122        'fields': ('first_name', 'last_name', 'address', 'city', 'state'), 
     
    117126    tuple. In this example, the ``first_name`` and ``last_name`` fields will 
    118127    display on the same line:: 
    119          
     128 
    120129        { 
    121130        'fields': (('first_name', 'last_name'), 'address', 'city', 'state'), 
     
    123132 
    124133``classes`` 
    125     A string containing extra CSS classes to apply to the fieldset. 
    126      
     134    A list containing extra CSS classes to apply to the fieldset. 
     135 
    127136    Example:: 
    128          
     137 
    129138        { 
    130         'classes': 'wide'
     139        'classes': ['wide', 'extrapretty']
    131140        } 
    132141 
    133     Apply multiple classes by separating them with spaces. Example:: 
    134          
    135         { 
    136         'classes': 'wide extrapretty', 
    137         } 
    138      
    139142    Two useful classes defined by the default admin-site stylesheet are 
    140143    ``collapse`` and ``wide``. Fieldsets with the ``collapse`` style will be 
     
    144147``description`` 
    145148    A string of optional extra text to be displayed at the top of each fieldset, 
    146     under the heading of the fieldset. It's used verbatim, so you can use any HTML 
    147     and you must escape any special HTML characters (such as ampersands) yourself. 
     149    under the heading of the fieldset. 
     150 
     151    Note that this value is *not* HTML-escaped when it's displayed in 
     152    the admin interface. This lets you include HTML if you so desire. 
     153    Alternatively you can use plain text and 
     154    ``django.utils.html.escape()`` to escape any HTML special 
     155    characters. 
     156 
     157``fields`` 
     158~~~~~~~~~~ 
     159 
     160Use this option as an alternative to ``fieldsets`` if the layout does not 
     161matter and if you want to only show a subset of the available fields in the 
     162form. For example, you could define a simpler version of the admin form for 
     163the ``django.contrib.flatpages.FlatPage`` model as follows:: 
     164 
     165    class FlatPageAdmin(admin.ModelAdmin): 
     166        fields = ('url', 'title', 'content') 
     167 
     168In the above example, only the fields 'url', 'title' and 'content' will be 
     169displayed, sequencially, in the form. 
     170 
     171.. admonition:: Note 
     172 
     173    This ``fields`` option should not be confused with the ``fields`` 
     174    dictionary key that is within the ``fieldsets`` option, as described in 
     175    the previous section. 
    148176 
    149177``filter_horizontal`` 
    150178~~~~~~~~~~~~~~~~~~~~~ 
    151179 
    152 Use a nifty unobtrusive Javascript "filter" interface instead of the 
     180Use a nifty unobtrusive JavaScript "filter" interface instead of the 
    153181usability-challenged ``<select multiple>`` in the admin form. The value is a 
    154182list of fields that should be displayed as a horizontal filter interface. See 
     
    193221 
    194222      Here's a full example model:: 
    195            
     223 
    196224          class Person(models.Model): 
    197225              name = models.CharField(max_length=50) 
     
    201229                  return self.birthday.strftime('%Y')[:3] + "0's" 
    202230              decade_born_in.short_description = 'Birth decade' 
    203            
     231 
    204232          class PersonAdmin(admin.ModelAdmin): 
    205233              list_display = ('name', 'decade_born_in') 
     
    219247                  return '<span style="color: #%s;">%s %s</span>' % (self.color_code, self.first_name, self.last_name) 
    220248              colored_name.allow_tags = True 
    221            
     249 
    222250          class PersonAdmin(admin.ModelAdmin): 
    223251              list_display = ('first_name', 'last_name', 'colored_name') 
     
    236264                  return self.birthday.strftime('%Y')[:3] == 5 
    237265              born_in_fifties.boolean = True 
    238            
     266 
    239267          class PersonAdmin(admin.ModelAdmin): 
    240268              list_display = ('name', 'born_in_fifties') 
     
    265293            colored_first_name.allow_tags = True 
    266294            colored_first_name.admin_order_field = 'first_name' 
    267          
     295 
    268296        class PersonAdmin(admin.ModelAdmin): 
    269297            list_display = ('first_name', 'colored_first_name') 
     
    356384If this isn't provided, the Django admin will use the model's default ordering. 
    357385 
     386.. admonition:: Note 
     387 
     388    Django will only honor the first element in the list/tuple; any others 
     389    will be ignored. 
     390 
    358391``prepopulated_fields`` 
    359392~~~~~~~~~~~~~~~~~~~~~~~ 
     
    365398        prepopulated_fields = {"slug": ("title",)} 
    366399 
    367 When set the given fields will use a bit of Javascript to populate from the 
    368 fields assigned. 
    369  
    370 ``prepopulated_fields`` doesn't accept DateTimeFields, ForeignKeys nor 
    371 ManyToManyFields. 
     400When set, the given fields will use a bit of JavaScript to populate from the 
     401fields assigned. The main use for this functionality is to automatically 
     402generate the value for ``SlugField`` fields from one or more other fields. The 
     403generated value is produced by concatenating the values of the source fields, 
     404and then by transforming that result into a valid slug (e.g. substituting 
     405dashes for spaces). 
     406 
     407``prepopulated_fields`` doesn't accept ``DateTimeField``, ``ForeignKey``, nor 
     408``ManyToManyField`` fields. 
    372409 
    373410``radio_fields`` 
     
    397434 
    398435``raw_id_fields`` is a list of fields you would like to change 
    399 into a ``Input`` widget for the primary key. 
     436into a ``Input`` widget for either a ``ForeignKey`` or ``ManyToManyField``:: 
     437 
     438    class ArticleAdmin(admin.ModelAdmin): 
     439        raw_id_fields = ("newspaper",) 
    400440 
    401441``save_as`` 
     
    485525-------------------------------- 
    486526 
    487 There are times where you would like add a bit of CSS and/or Javascript to 
     527There are times where you would like add a bit of CSS and/or JavaScript to 
    488528the add/change views. This can be accomplished by using a Media inner class 
    489529on your ``ModelAdmin``:: 
     
    499539apply as `regular media definitions on forms`_. 
    500540 
    501 .. _regular media definitions on forms: ../newforms/#media 
     541.. _regular media definitions on forms: ../forms/#media 
     542 
     543Adding custom validation to the admin 
     544------------------------------------- 
     545 
     546Adding custom validation of data in the admin is quite easy. The automatic 
     547admin interfaces reuses the Django `forms`_ module. The ``ModelAdmin`` class 
     548gives you the ability define your own form:: 
     549 
     550    class ArticleAdmin(admin.ModelAdmin): 
     551        form = MyArticleAdminForm 
     552 
     553``MyArticleAdminForm`` can be defined anywhere as long as you import where 
     554needed. Now within your form you can add your own custom validation for 
     555any field:: 
     556     
     557    class MyArticleAdminForm(forms.ModelForm): 
     558        def clean_name(self): 
     559            # do something that validates your data 
     560            return self.cleaned_data["name"] 
     561 
     562It is important you use a ``ModelForm`` here otherwise things can break. See 
     563the `forms`_ documentation on `custom validation`_ for more information. 
     564 
     565.. _forms: ../forms/ 
     566.. _custom validation: ../forms/#custom-form-and-field-validation 
    502567 
    503568``InlineModelAdmin`` objects 
     
    505570 
    506571The admin interface has the ability to edit models on the same page as a 
    507 parent model. These are called inlines. You can add them a model being 
    508 specifing them in a ``ModelAdmin.inlines`` attribute:: 
     572parent model. These are called inlines. You can add them to a model by 
     573specifying them in a ``ModelAdmin.inlines`` attribute:: 
    509574 
    510575    class BookInline(admin.TabularInline): 
    511576        model = Book 
    512      
     577 
    513578    class AuthorAdmin(admin.ModelAdmin): 
    514579        inlines = [ 
     
    516581        ] 
    517582 
    518 Django provides two subclasses of ``InlineModelAdmin`` and they are:: 
     583Django provides two subclasses of ``InlineModelAdmin`` and they are: 
    519584 
    520585    * ``TabularInline`` 
     
    563628to the initial forms. See the `formsets documentation`_ for more information. 
    564629 
    565 .. _formsets documentation: ../newforms/#formsets 
     630.. _formsets documentation: ../forms/#formsets 
    566631 
    567632``max_num`` 
     
    574639.. _max_num in formsets: ../modelforms/#limiting-the-number-of-objects-editable 
    575640 
     641``raw_id_fields`` 
     642~~~~~~~~~~~~~~~~~ 
     643 
     644By default, Django's admin uses a select-box interface (<select>) for 
     645fields that are ``ForeignKey``. Sometimes you don't want to incur the 
     646overhead of having to select all the related instances to display in the 
     647drop-down. 
     648 
     649``raw_id_fields`` is a list of fields you would like to change 
     650into a ``Input`` widget for either a ``ForeignKey`` or ``ManyToManyField``:: 
     651 
     652    class BookInline(admin.TabularInline): 
     653        model = Book 
     654        raw_id_fields = ("pages",) 
     655 
    576656``template`` 
    577657~~~~~~~~~~~~ 
     
    599679        to_person = models.ForeignKey(Person, related_name="friends") 
    600680        from_person = models.ForeignKey(Person, related_name="from_friends") 
    601      
     681 
    602682If you wanted to display an inline on the ``Person`` admin add/change pages 
    603683you need to explicitly define the foreign key since it is unable to do so 
     
    607687        model = Friendship 
    608688        fk_name = "to_person" 
    609      
     689 
    610690    class PersonAdmin(admin.ModelAdmin): 
    611691        inlines = [ 
     
    613693        ] 
    614694 
     695Working with Many-to-Many Intermediary Models 
     696---------------------------------------------- 
     697 
     698By default, admin widgets for many-to-many relations will be displayed inline 
     699on whichever model contains the actual reference to the ``ManyToManyField``. 
     700However, when you specify an intermediary model using the ``through`` 
     701argument to a ``ManyToManyField``, the admin will not display a widget by  
     702default. This is because each instance of that intermediary model requires 
     703more information than could be displayed in a single widget, and the layout 
     704required for multiple widgets will vary depending on the intermediate model. 
     705 
     706However, we still want to be able to edit that information inline. Fortunately, 
     707this is easy to do with inline admin models. Suppose we have the following 
     708models:: 
     709 
     710    class Person(models.Model): 
     711        name = models.CharField(max_length=128) 
     712     
     713    class Group(models.Model): 
     714        name = models.CharField(max_length=128) 
     715        members = models.ManyToManyField(Person, through='Membership') 
     716 
     717    class Membership(models.Model): 
     718        person = models.ForeignKey(Person) 
     719        group = models.ForeignKey(Group) 
     720        date_joined = models.DateField() 
     721        invite_reason = models.CharField(max_length=64) 
     722 
     723The first step in displaying this intermediate model in the admin is to 
     724define an inline class for the ``Membership`` model:: 
     725 
     726    class MembershipInline(admin.TabularInline): 
     727        model = Membership 
     728        extra = 1 
     729 
     730This simple example uses the default ``InlineModelAdmin`` values for the 
     731``Membership`` model, and limits the extra add forms to one. This could be 
     732customized using any of the options available to ``InlineModelAdmin`` classes. 
     733 
     734Now create admin views for the ``Person`` and ``Group`` models:: 
     735 
     736    class PersonAdmin(admin.ModelAdmin): 
     737        inlines = (MembershipInline,) 
     738 
     739    class GroupAdmin(admin.ModelAdmin): 
     740        inlines = (MembershipInline,) 
     741 
     742Finally, register your ``Person`` and ``Group`` models with the admin site:: 
     743     
     744    admin.site.register(Person, PersonAdmin) 
     745    admin.site.register(Group, GroupAdmin) 
     746 
     747Now your admin site is set up to edit ``Membership`` objects inline from 
     748either the ``Person`` or the ``Group`` detail pages. 
     749 
    615750``AdminSite`` objects 
    616751===================== 
     
    629764    from django.conf.urls.defaults import * 
    630765    from django.contrib import admin 
    631      
     766 
    632767    admin.autodiscover() 
    633768 
  • django/branches/gis/docs/api_stability.txt

    r7354 r8215  
    6060   - `Request/response objects`_. 
    6161    
    62    - `Sending email`_. 
     62   - `Sending e-mail`_. 
    6363    
    6464   - `Sessions`_. 
     
    109109.. _redirects: ../redirects/ 
    110110.. _request/response objects: ../request_response/ 
    111 .. _sending email: ../email/ 
     111.. _sending e-mail: ../email/ 
    112112.. _sessions: ../sessions/ 
    113113.. _settings: ../settings/ 
     
    116116.. _transactions: ../transactions/ 
    117117.. _url dispatch: ../url_dispatch/ 
    118 .. _forms and validation: ../forms/ 
    119118.. _serialization: ../serialization/ 
    120119.. _authentication: ../authentication/ 
  • django/branches/gis/docs/authentication.txt

    r7979 r8215  
    518518 
    519519    * ``form``: A ``Form`` object representing the login form. See the 
    520       `newforms documentation`_ for more on ``Form`` objects. 
     520      `forms documentation`_ for more on ``FormWrapper`` objects. 
    521521    * ``next``: The URL to redirect to after successful login. This may contain 
    522522      a query string, too. 
     
    558558    {% endblock %} 
    559559 
    560 .. _newforms documentation: ../newforms/ 
     560.. _forms documentation: ../forms/ 
    561561.. _site framework docs: ../sites/ 
    562562 
     
    632632 
    633633Allows a user to reset their password, and sends them the new password 
    634 in an email. 
     634in an e-mail. 
    635635 
    636636**Optional arguments:** 
     
    641641 
    642642    * ``email_template_name``: The full name of a template to use for 
    643       generating the email with the new password. This will default to 
     643      generating the e-mail with the new password. This will default to 
    644644      ``registration/password_reset_email.html`` if not supplied. 
    645645 
     
    697697 
    698698    * ``django.contrib.auth.forms.PasswordResetForm``: A form for resetting a 
    699       user's password and emailing the new password to them. 
     699      user's password and e-mailing the new password to them. 
    700700 
    701701    * ``django.contrib.auth.forms.UserCreationForm``: A form for creating a 
  • django/branches/gis/docs/cache.txt

    r7768 r8215  
    77from database queries to template rendering to business logic -- to create the 
    88page that your site's visitor sees. This is a lot more expensive, from a 
    9 processing-overhead perspective, than your standard read-a-file-off-the-filesystem 
    10 server arrangement. 
     9processing-overhead perspective, than your standard 
     10read-a-file-off-the-filesystem server arrangement. 
    1111 
    1212For most Web applications, this overhead isn't a big deal. Most Web 
     
    160160    CACHE_BACKEND = 'locmem:///' 
    161161 
    162 Simple caching (for development) 
    163 -------------------------------- 
    164  
    165 A simple, single-process memory cache is available as ``"simple:///"``. This 
    166 merely saves cached data in-process, which means it should only be used in 
    167 development or testing environments. For example:: 
    168  
    169     CACHE_BACKEND = 'simple:///' 
    170  
    171 **New in Django development version:** This cache backend is deprecated and 
    172 will be removed in a future release. New code should use the ``locmem`` backend 
    173 instead. 
    174  
    175162Dummy caching (for development) 
    176163------------------------------- 
     
    186173 
    187174    CACHE_BACKEND = 'dummy:///' 
     175 
     176Using a custom cache backend 
     177---------------------------- 
     178 
     179**New in Django development version** 
     180 
     181While Django includes support for a number of cache backends out-of-the-box, 
     182sometimes you will want to use a customised verison or your own backend.  To 
     183use an external cache backend with Django, use a Python import path as the 
     184scheme portion (the part before the initial colon) of the ``CACHE_BACKEND`` 
     185URI, like so:: 
     186 
     187    CACHE_BACKEND = 'path.to.backend://' 
     188 
     189If you're building your own backend, you can use the standard cache backends 
     190as reference implementations. You'll find the code in the 
     191``django/core/cache/backends/`` directory of the Django source. 
     192 
     193Note: Without a really compelling reason, like a host that doesn't support the 
     194them, you should stick to the cache backends included with Django. They've 
     195been really well-tested and are quite easy to use. 
    188196 
    189197CACHE_BACKEND arguments 
  • django/branches/gis/docs/contenttypes.txt

    r7979 r8215  
    206206       ``IntegerField`` or ``PositiveIntegerField``.) 
    207207 
    208           This field must be of the same type as the primary key of the models 
    209           that will be involved in the generic relation. For example, if you use 
    210           ``IntegerField``, you won't be able to form a generic relation with a 
    211           model that uses a ``CharField`` as a primary key. 
     208       This field must be of the same type as the primary key of the models 
     209       that will be involved in the generic relation. For example, if you use 
     210       ``IntegerField``, you won't be able to form a generic relation with a 
     211       model that uses a ``CharField`` as a primary key. 
    212212 
    213213    3. Give your model a ``GenericForeignKey``, and pass it the names of 
  • django/branches/gis/docs/contributing.txt

    r7918 r8215  
    526526        * All database fields 
    527527        * ``class Meta`` 
    528         * ``class Admin`` 
    529528        * ``def __unicode__()`` 
    530529        * ``def __str__()`` 
  • django/branches/gis/docs/csrf.txt

    r7354 r8215  
    55The CsrfMiddleware class provides easy-to-use protection against 
    66`Cross Site Request Forgeries`_.  This type of attack occurs when a malicious 
    7 web site creates a link or form button that is intended to perform some action 
    8 on your web site, using the credentials of a logged-in user who is tricked 
     7Web site creates a link or form button that is intended to perform some action 
     8on your Web site, using the credentials of a logged-in user who is tricked 
    99into clicking on the link in their browser. 
    1010 
     
    3939   isn't, the user will get a 403 error. 
    4040 
    41 This ensures that only forms that have originated from your web site 
     41This ensures that only forms that have originated from your Web site 
    4242can be used to POST data back. 
    4343 
     
    4848 
    4949POST requests that are not accompanied by a session cookie are not protected, 
    50 but they do not need to be protected, since the 'attacking' web site 
     50but they do not need to be protected, since the 'attacking' Web site 
    5151could make these kind of requests anyway. 
    5252 
     
    6565 
    6666If your app creates HTML pages and forms in some unusual way, (e.g. 
    67 it sends fragments of HTML in javascript document.write statements) 
     67it sends fragments of HTML in JavaScript document.write statements) 
    6868you might bypass the filter that adds the hidden field to the form, 
    6969in which case form submission will always fail.  It may still be possible 
  • django/branches/gis/docs/custom_model_fields.txt

    r7979 r8215  
    112112of the class behavior. 
    113113 
    114 .. _form fields: ../newforms/#fields 
     114.. _form fields: ../forms/#fields 
    115115 
    116116It's important to realize that a Django field class is not what is stored in 
     
    386386mentioned earlier. Otherwise ``to_python()`` won't be called automatically. 
    387387 
    388 ``get_db_prep_save(self, value)`` 
    389 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     388``get_db_prep_value(self, value)`` 
     389~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    390390 
    391391This is the reverse of ``to_python()`` when working with the database backends 
     
    400400        # ... 
    401401 
    402         def get_db_prep_save(self, value): 
     402        def get_db_prep_value(self, value): 
    403403            return ''.join([''.join(l) for l in (value.north, 
    404404                    value.east, value.south, value.west)]) 
     405 
     406``get_db_prep_save(self, value)`` 
     407~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     408 
     409Same as the above, but called when the Field value must be *saved* to the 
     410database. As the default implementation just calls ``get_db_prep_value``, you 
     411shouldn't need to implement this method unless your custom field need a special 
     412conversion when being saved that is not the same as the used for normal query 
     413parameters (which is implemented by ``get_db_prep_value``). 
     414 
    405415 
    406416``pre_save(self, model_instance, add)`` 
     
    441451 
    442452If you needed to implement ``get_db_prep_save()``, you will usually need to 
    443 implement ``get_db_prep_lookup()``. The usual reason is because of the 
    444 ``range``  and ``in`` lookups. In these case, you will passed a list of 
    445 objects (presumably of the right type) and will need to convert them to a list 
    446 of things of the right type for passing to the database. Sometimes you can 
    447 reuse ``get_db_prep_save()``, or at least factor out some common pieces from 
    448 both methods into a help function. 
    449  
    450 For example:: 
     453implement ``get_db_prep_lookup()``. If you don't, ``get_db_prep_value`` will be 
     454called by the default implementation, to manage ``exact``, ``gt``, ``gte``, 
     455``lt``, ``lte``, ``in`` and ``range`` lookups. 
     456 
     457You may also want to implement this method to limit the lookup types that could 
     458be used with your custom field type. 
     459 
     460Note that, for ``range`` and ``in`` lookups, ``get_db_prep_lookup`` will receive 
     461a list of objects (presumably of the right type) and will need to convert them 
     462to a list of things of the right type for passing to the database. Most of the 
     463time, you can reuse ``get_db_prep_value()``, or at least factor out some common 
     464pieces. 
     465 
     466For example, the following code implements ``get_db_prep_lookup`` to limit the 
     467accepted lookup types to ``exact`` and ``in``:: 
    451468 
    452469    class HandField(models.Field): 
     
    456473            # We only handle 'exact' and 'in'. All others are errors. 
    457474            if lookup_type == 'exact': 
    458                 return self.get_db_prep_save(value) 
     475                return self.get_db_prep_value(value) 
    459476            elif lookup_type == 'in': 
    460                 return [self.get_db_prep_save(v) for v in value] 
     477                return [self.get_db_prep_value(v) for v in value] 
    461478            else: 
    462479                raise TypeError('Lookup type %r not supported.' % lookup_type) 
     
    494511fields. 
    495512 
    496 .. _helper functions: ../newforms/#generating-forms-for-models 
    497 .. _forms documentation: ../newforms/ 
     513.. _helper functions: ../forms/#generating-forms-for-models 
     514.. _forms documentation: ../forms/ 
    498515 
    499516``get_internal_type(self)`` 
     
    539556    serialization, the API might change in the future. 
    540557 
    541 Returns a dictionary, mapping the field's attribute name to a flattened string 
    542 version of the data. This method has some internal uses that aren't of 
    543 interest to use here (mostly having to do with manipulators). For our 
    544 purposes, it's sufficient to return a one item dictionary that maps the 
    545 attribute name to a string. 
     558Returns a dictionary, mapping the field's attribute name to a 
     559flattened string version of the data. This method has some internal 
     560uses that aren't of interest to use here (mostly having to do with 
     561forms). For our purposes, it's sufficient to return a one item 
     562dictionary that maps the attribute name to a string. 
    546563 
    547564This method is used by the serializers to convert the field into a string for 
     
    558575        def flatten_data(self, follow, obj=None): 
    559576            value = self._get_val_from_obj(obj) 
    560             return {self.attname: self.get_db_prep_save(value)} 
     577            return {self.attname: self.get_db_prep_value(value)} 
    561578 
    562579Some general advice 
  • django/branches/gis/docs/databases.txt

    r7354 r8215  
    193193To run Django's test suite, the user needs these *additional* privileges: 
    194194 
    195         * CREATE DATABASE 
    196         * DROP DATABASE 
     195        * CREATE USER 
     196        * DROP USER 
    197197        * CREATE TABLESPACE 
    198198        * DROP TABLESPACE 
  • django/branches/gis/docs/db-api.txt

    r7918 r8215  
    464464``extra()`` calls, Django will not inspect these fragments to see if they need 
    465465to be rewritten because of changes in the merged query. So test the effects 
    466 carefully. Also realise that if you are combining two ``QuerySets`` with 
     466carefully. Also realize that if you are combining two ``QuerySets`` with 
    467467``|``, you cannot use ``extra(select=...)`` or ``extra(where=...)`` on *both* 
    468468``QuerySets``. You can only use those calls on one or the other (Django will 
     
    16771677    Blog.objects.filter(entry__headline__contains='Lennon') 
    16781678 
     1679If you are filtering across multiple relationships and one of the intermediate 
     1680models doesn't have a value that meets the filter condition, Django will treat 
     1681it as if there is an empty (all values are ``NULL``), but valid, object there. 
     1682All 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`` 
     1687associated with an entry, it would be treated as if there was also no ``name`` 
     1688attached, rather than raising an error because of the missing ``author``. 
     1689Usually this is exactly what you want to have happen. The only case where it 
     1690might be confusing is if you are using ``isnull``. Thus:: 
     1691 
     1692    Blog.objects.filter(entry__author__name__isnull=True) 
     1693 
     1694will return ``Blog`` objects that have an empty ``name`` on the ``author`` and 
     1695also those which have an empty ``author`` on the ``entry``. If you don't want 
     1696those latter objects, you could write:: 
     1697 
     1698    Blog.objetcs.filter(entry__author__isnull=False, 
     1699            entry__author__name__isnull=True) 
     1700 
    16791701Spanning multi-valued relationships 
    16801702~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    22192241every item in a ``QuerySet`` and make sure that the ``save()`` method is 
    22202242called on each instance, you don't need any special function to handle that. 
    2221 Just loop over them and call ``save()``: 
     2243Just loop over them and call ``save()``:: 
    22222244 
    22232245    for item in my_queryset: 
     
    22812303to the file, according to your ``MEDIA_ROOT`` setting. 
    22822304 
     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 
    22832310Note that ``ImageField`` is technically a subclass of ``FileField``, so every 
    22842311model with an ``ImageField`` will also get this method. 
     
    22912318according to your ``MEDIA_URL`` setting. If the value is blank, this method 
    22922319returns 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. 
    22932325 
    22942326get_FOO_size() 
  • django/branches/gis/docs/django-admin.txt

    r7918 r8215  
    396396Runs over the entire source tree of the current directory and pulls out all 
    397397strings marked for translation. It creates (or updates) a message file in the 
    398 conf/locale (in the django tree) or locale (for project and application) 
     398conf/locale (in the Django tree) or locale (for project and application) 
    399399directory. After making changes to the messages files you need to compile them 
    400400with ``compilemessages`` for use with the builtin gettext support. See the 
  • django/branches/gis/docs/email.txt

    r7354 r8215  
    180180            return HttpResponseRedirect('/contact/thanks/') 
    181181        else: 
    182             # In reality we'd use a manipulator 
     182            # In reality we'd use a form class 
    183183            # to get proper validation errors. 
    184184            return HttpResponse('Make sure all fields are entered and valid.') 
  • django/branches/gis/docs/faq.txt

    r7642 r8215  
    225225--------------------------------- 
    226226 
    227 Short answer: When we're comfortable with Django's APIs, have added all 
    228 features that we feel are necessary to earn a "1.0" status, and are ready to 
    229 begin maintaining backwards compatibility. 
    230  
    231 The merging of Django's `Queryset Refactor branch`_ went a long way toward Django 
    232 1.0. Merging the `Newforms Admin branch` will be another important step. 
    233  
    234 Of course, you should note that `quite a few production sites`_ use Django in 
    235 its current status. Don't let the lack of a 1.0 turn you off. 
    236  
    237 .. _Queryset Refactor branch: http://code.djangoproject.com/wiki/QuerysetRefactorBranch 
    238 .. _Newforms Admin branch: http://code.djangoproject.com/wiki/NewformsAdminBranch 
    239 .. _quite a few production sites: http://code.djangoproject.com/wiki/DjangoPoweredSites 
     227See our `version one roadmap`_ for the detailed timeline. We're aiming for 
     228September 2, 2008. 
     229 
     230.. _version one roadmap: http://code.djangoproject.com/wiki/VersionOneRoadmap 
    240231 
    241232How can I download the Django documentation to read it offline? 
     
    435426 
    436427    #. All that will be stored in your database is a path to the file 
    437        (relative to ``MEDIA_ROOT``). You'll must likely want to use the 
     428       (relative to ``MEDIA_ROOT``). You'll most likely want to use the 
    438429       convenience ``get_<fieldname>_url`` function provided by Django. For 
    439430       example, if your ``ImageField`` is called ``mug_shot``, you can get the 
  • django/branches/gis/docs/fastcgi.txt

    r7354 r8215  
    8080list of all the available options. 
    8181 
    82 You'll need to specify either a ``socket``, ``protocol`` or both ``host`` and ``port``. 
    83 Then, when you set up your Web server, you'll just need to point it at the host/por
    84 or socket you specified when starting the FastCGI server. 
     82You'll need to specify either a ``socket``, ``protocol`` or both ``host`` and 
     83``port``. Then, when you set up your Web server, you'll just need to point i
     84at the host/port or socket you specified when starting the FastCGI server. 
    8585 
    8686Protocols 
     
    209209 
    210210.. _mod_rewrite: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html 
     211 
     212Django will automatically use the pre-rewrite version of the URL when 
     213constructing URLs with the ``{% url %}`` template tag (and similar methods). 
    211214 
    212215lighttpd setup 
     
    337340.. _modpython: ../modpython/#serving-the-admin-files 
    338341 
     342Forcing the URL prefix to a particular value 
     343============================================ 
     344 
     345Because many of these fastcgi-based solutions require rewriting the URL at 
     346some point inside th