Ticket #3540: permalink_docs.patch

File permalink_docs.patch, 1.1 KB (added by Chris Beaven, 18 years ago)
  • docs/model-api.txt

     
    17571757in the URLConf file and in the model.
    17581758
    17591759You 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::
     1760decorator. This decorator is passed the view function, a list of ordered
     1761parameters and (optionally) a dictionary of named parameters you would use for
     1762accessing this instance directly. Django then works out the correct full URL
     1763path using the URLconf. For example::
    17631764
    17641765    from django.db.models import permalink
    17651766
    17661767    def get_absolute_url(self):
    1767         return ('people.views.details', str(self.id))
     1768        return ('people.views.details', [self.id])
    17681769    get_absolute_url = permalink(get_absolute_url)
    17691770
    17701771In this way, you're tying the model's absolute URL to the view that is used
Back to Top