Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit da1d001ce1105fb3f34c07fa75018e8137e3ece5 1 parent 99fbb7b
Adrian Holovaty authored April 01, 2007

Showing 1 changed file with 8 additions and 10 deletions. Show diff stats Hide diff stats

  1. 18  docs/model-api.txt
18  docs/model-api.txt
@@ -1307,13 +1307,13 @@ A few special cases to note about ``list_display``:
1307 1307
     * Usually, elements of ``list_display`` that aren't actual database fields
1308 1308
       can't be used in sorting (because Django does all the sorting at the
1309 1309
       database level).
1310  
-      
  1310
+
1311 1311
       However, if an element of ``list_display`` represents a certain database
1312 1312
       field, you can indicate this fact by setting the ``admin_order_field``
1313 1313
       attribute of the item.
1314  
-      
  1314
+
1315 1315
       For example::
1316  
-      
  1316
+
1317 1317
         class Person(models.Model):
1318 1318
             first_name = models.CharField(maxlength=50)
1319 1319
             color_code = models.CharField(maxlength=6)
@@ -1325,7 +1325,7 @@ A few special cases to note about ``list_display``:
1325 1325
                 return '<span style="color: #%s;">%s</span>' % (self.color_code, self.first_name)
1326 1326
             colored_first_name.allow_tags = True
1327 1327
             colored_first_name.admin_order_field = 'first_name'
1328  
-    
  1328
+
1329 1329
       The above will tell Django to order by the ``first_name`` field when
1330 1330
       trying to sort by ``colored_first_name`` in the admin.
1331 1331
 
@@ -1759,7 +1759,7 @@ in the URLConf file and in the model.
1759 1759
 
1760 1760
 You can further decouple your models from the URLconf using the ``permalink``
1761 1761
 decorator. This decorator is passed the view function, a list of positional
1762  
-parameters and (optionally) a dictionary of named parameters.  Django then
  1762
+parameters and (optionally) a dictionary of named parameters. Django then
1763 1763
 works out the correct full URL path using the URLconf, substituting the
1764 1764
 parameters you have given into the URL. For example, if your URLconf
1765 1765
 contained a line such as::
@@ -1774,11 +1774,9 @@ contained a line such as::
1774 1774
         return ('people.views.details', [str(self.id)])
1775 1775
     get_absolute_url = permalink(get_absolute_url)
1776 1776
 
  1777
+Similarly, if you had a URLconf entry that looked like::
1777 1778
 
1778  
-Similraly, if you had a URLconf entry that looked like::
1779  
-
1780  
-    (r'/archive/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$',
1781  
-        archive_view)
  1779
+    (r'/archive/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', archive_view)
1782 1780
 
1783 1781
 ...you could reference this using ``permalink()`` as follows::
1784 1782
 
@@ -1790,7 +1788,7 @@ Similraly, if you had a URLconf entry that looked like::
1790 1788
     get_absolute_url = permalink(get_absolute_url)
1791 1789
 
1792 1790
 Notice that we specify an empty sequence for the second argument in this case,
1793  
-since we're only wanting to pass in some keyword arguments.
  1791
+because we only want to pass keyword arguments, not named arguments.
1794 1792
 
1795 1793
 In this way, you're tying the model's absolute URL to the view that is used
1796 1794
 to display it, without repeating the URL information anywhere. You can still

0 notes on commit da1d001

Please sign in to comment.
Something went wrong with that request. Please try again.