summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-04-01 05:22:14 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-04-01 05:22:14 +0000
commitda1d001ce1105fb3f34c07fa75018e8137e3ece5 (patch)
tree3968da6b797d46f0fdf29b0e2d51555cb68e5619 /docs
parent99fbb7b62b61b3e4beef99f46132567082adbea9 (diff)
Edited docs/model-api.txt permalink changes from [4879]
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4891 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/model-api.txt18
1 files changed, 8 insertions, 10 deletions
diff --git a/docs/model-api.txt b/docs/model-api.txt
index 3f5a8ff416..a03ed09eb2 100644
--- a/docs/model-api.txt
+++ b/docs/model-api.txt
@@ -1307,13 +1307,13 @@ A few special cases to note about ``list_display``:
* Usually, elements of ``list_display`` that aren't actual database fields
can't be used in sorting (because Django does all the sorting at the
database level).
-
+
However, if an element of ``list_display`` represents a certain database
field, you can indicate this fact by setting the ``admin_order_field``
attribute of the item.
-
+
For example::
-
+
class Person(models.Model):
first_name = models.CharField(maxlength=50)
color_code = models.CharField(maxlength=6)
@@ -1325,7 +1325,7 @@ A few special cases to note about ``list_display``:
return '<span style="color: #%s;">%s</span>' % (self.color_code, self.first_name)
colored_first_name.allow_tags = True
colored_first_name.admin_order_field = 'first_name'
-
+
The above will tell Django to order by the ``first_name`` field when
trying to sort by ``colored_first_name`` in the admin.
@@ -1759,7 +1759,7 @@ 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, a list of positional
-parameters and (optionally) a dictionary of named parameters. Django then
+parameters and (optionally) a dictionary of named parameters. Django then
works out the correct full URL path using the URLconf, substituting the
parameters you have given into the URL. For example, if your URLconf
contained a line such as::
@@ -1774,11 +1774,9 @@ contained a line such as::
return ('people.views.details', [str(self.id)])
get_absolute_url = permalink(get_absolute_url)
+Similarly, if you had a URLconf entry that looked like::
-Similraly, if you had a URLconf entry that looked like::
-
- (r'/archive/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$',
- archive_view)
+ (r'/archive/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', archive_view)
...you could reference this using ``permalink()`` as follows::
@@ -1790,7 +1788,7 @@ Similraly, if you had a URLconf entry that looked like::
get_absolute_url = permalink(get_absolute_url)
Notice that we specify an empty sequence for the second argument in this case,
-since we're only wanting to pass in some keyword arguments.
+because we only want to pass keyword arguments, not named arguments.
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