From 67e0248806e8adc03ddd81e9543f77b540ed1673 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 20 Feb 2007 00:41:14 +0000 Subject: newforms-admin: Merged to [4545] git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@4546 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/add_ons.txt | 9 ++++ docs/model-api.txt | 38 +++++++++---- docs/newforms.txt | 47 ++++++++++++++-- docs/request_response.txt | 115 +++++++++++++++++++++++++++++++++++++++ docs/testing.txt | 135 ++++++++++++++++++++++++---------------------- 5 files changed, 267 insertions(+), 77 deletions(-) (limited to 'docs') diff --git a/docs/add_ons.txt b/docs/add_ons.txt index d937eb2141..1756fe5720 100644 --- a/docs/add_ons.txt +++ b/docs/add_ons.txt @@ -139,6 +139,15 @@ See the `flatpages documentation`_. .. _flatpages documentation: ../flatpages/ +localflavor +=========== + +**New in Django development version** + +A collection of various Django snippets that are useful only for a particular +country or culture. For example, ``django.contrib.localflavor.usa.forms`` +contains a ``USZipCodeField`` that you can use to validate U.S. zip codes. + markup ====== diff --git a/docs/model-api.txt b/docs/model-api.txt index 8abd88f7ec..0a10918d54 100644 --- a/docs/model-api.txt +++ b/docs/model-api.txt @@ -874,8 +874,8 @@ the relationship should work. All are optional: force Django to add the descriptor for the reverse relationship, allowing ``ManyToMany`` relationships to be non-symmetrical. - - ``db_table`` The name of the table to create for storing the many-to-many + + ``db_table`` The name of the table to create for storing the many-to-many data. If this is not provided, Django will assume a default name based upon the names of the two tables being joined. @@ -1272,8 +1272,8 @@ A few special cases to note about ``list_display``: return '%s %s' % (self.color_code, self.first_name, self.last_name) colored_name.allow_tags = True - * If the string given is a method of the model that returns True or False - Django will display a pretty "on" or "off" icon if you give the method a + * If the string given is a method of the model that returns True or False + Django will display a pretty "on" or "off" icon if you give the method a ``boolean`` attribute whose value is ``True``. Here's a full example model:: @@ -1412,7 +1412,7 @@ This should be set to a list of field names that will be searched whenever somebody submits a search query in that text box. These fields should be some kind of text field, such as ``CharField`` or -``TextField``. You can also perform a related lookup on a ``ForeignKey`` with +``TextField``. You can also perform a related lookup on a ``ForeignKey`` with the lookup API "follow" notation:: search_fields = ['foreign_key__related_fieldname'] @@ -1721,11 +1721,29 @@ But this template code is good:: {{ object.name }} -(Yes, we know ``get_absolute_url()`` couples URLs to models, which violates the -DRY principle, because URLs are defined both in a URLconf and in the model. -This is a rare case in which we've intentionally violated that principle for -the sake of convenience. With that said, we're working on an even cleaner way -of specifying URLs in a more DRY fashion.) +The ``permalink`` decorator +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**New in Django development version.** + +The problem with the way we wrote ``get_absolute_url()`` above is that it +slightly violates the DRY principle: the URL for this object is defined both +in the URLConf file and in the model. + +You can further decouple your models from the URLconf using the ``permalink`` +decorator. This decorator is passed the view function and any parameters you +would use for accessing this instance directly. Django then works out the +correct full URL path using the URLconf. For example:: + + from django.db.models import permalink + + def get_absolute_url(self): + return ('people.views.details', str(self.id)) + get_absolute_url = permalink(get_absolute_url) + +In this way, you're tying the model's absolute URL to the view that is used +to display it, without repeating the URL information anywhere. You can still +use the ``get_absolute_url`` method in templates, as before. Executing custom SQL -------------------- diff --git a/docs/newforms.txt b/docs/newforms.txt index 063f686ed5..33aaf14357 100644 --- a/docs/newforms.txt +++ b/docs/newforms.txt @@ -51,9 +51,10 @@ too messy. The choice is yours. Overview ======== -As with the ``django.forms`` ("manipulators") system before it, ``django.newforms`` -is intended to handle HTML form display, validation and redisplay. It's what -you use if you want to perform server-side validation for an HTML form. +As with the ``django.forms`` ("manipulators") system before it, +``django.newforms`` is intended to handle HTML form display, data processing +(validation) and redisplay. It's what you use if you want to perform +server-side validation for an HTML form. For example, if your Web site has a contact form that visitors can use to send you e-mail, you'd use this library to implement the display of the HTML @@ -571,6 +572,46 @@ is a list-like object that is displayed as an HTML ``