Ticket #3540: permalink_docs.patch
File permalink_docs.patch, 1.1 KB (added by , 18 years ago) |
---|
-
docs/model-api.txt
1757 1757 in the URLConf file and in the model. 1758 1758 1759 1759 You can further decouple your models from the URLconf using the ``permalink`` 1760 decorator. This decorator is passed the view function and any parameters you 1761 would use for accessing this instance directly. Django then works out the 1762 correct full URL path using the URLconf. For example:: 1760 decorator. This decorator is passed the view function, a list of ordered 1761 parameters and (optionally) a dictionary of named parameters you would use for 1762 accessing this instance directly. Django then works out the correct full URL 1763 path using the URLconf. For example:: 1763 1764 1764 1765 from django.db.models import permalink 1765 1766 1766 1767 def get_absolute_url(self): 1767 return ('people.views.details', str(self.id))1768 return ('people.views.details', [self.id]) 1768 1769 get_absolute_url = permalink(get_absolute_url) 1769 1770 1770 1771 In this way, you're tying the model's absolute URL to the view that is used