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.
    20032003
     2004You can also use a `named url pattern`_ like this::
     2005
     2006    url(r'^people/(\d+)/$', 'people.views.details', name='people_detail')
     2007
     2008...you could reference this using ``permalink()`` as follows::
     2009
     2010    def get_absolute_url(self):
     2011        return ('people_detail', [str(self.id)])
     2012    get_absolute_url = permalink(get_absolute_url)
     2013
    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.
    20072017
     2018.. _named url pattern: ../url_dispatch/#naming-url-patterns
     2019
    20082020Executing custom SQL
    20092021--------------------
    20102022
Back to Top