Changeset 4891
- Timestamp:
- 04/01/07 00:22:14 (2 years ago)
- Files:
-
- django/trunk/docs/model-api.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/model-api.txt
r4879 r4891 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) … … 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. … … 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 then1762 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 … … 1775 1775 get_absolute_url = permalink(get_absolute_url) 1776 1776 1777 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) 1777 Similarly, if you had a URLconf entry that looked like:: 1778 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:: … … 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
