Ticket #7003: 7003-permalink-docs.diff

File 7003-permalink-docs.diff, 1012 bytes (added by DavidReynolds, 7 years ago)

Documentation patch

  • docs/model-api.txt

    20012001Notice that we specify an empty sequence for the second parameter in this case,
    20022002because we only want to pass keyword parameters, not positional ones.
     2004You can also use a `named url pattern`_ like this::
     2006    url(r'^people/(\d+)/$', 'people.views.details', name='people_detail')
     2008...you could reference this using ``permalink()`` as follows::
     2010    def get_absolute_url(self):
     2011        return ('people_detail', [str(self.id)])
     2012    get_absolute_url = permalink(get_absolute_url)
    20042014In this way, you're tying the model's absolute URL to the view that is used
    20052015to display it, without repeating the URL information anywhere. You can still
    20062016use the ``get_absolute_url`` method in templates, as before.
     2018.. _named url pattern: ../url_dispatch/#naming-url-patterns
    20082020Executing custom SQL
Back to Top