Code

Changes between Version 10 and Version 11 of ReplacingGetAbsoluteUrl


Ignore:
Timestamp:
09/22/09 09:57:13 (5 years ago)
Author:
jojo
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ReplacingGetAbsoluteUrl

    v10 v11  
    1010== The problem == 
    1111 
    12 It's often useful for a model to "know" it's URL. This is especially true for sites that follow RESTful principles, where any entity within the site should have one and only one canonical URL. 
     12It's often useful for a model to "know" its URL. This is especially true for sites that follow RESTful principles, where any entity within the site should have one and only one canonical URL. 
    1313 
    1414It's also useful to keep URL logic in the same place as much as possible. Django's {% url %} template tag and reverse() function solve a slightly different problem - they resolve URLs for view functions, not for individual model objects, and treat the URLconf as the single point of truth for URLs. {% url myapp.views.profile user.id %} isn't as pragmatic as {{ user.get_absolute_url }}, since if we change the profile-view to take a username instead of a user ID in the URL we'll have to go back and update all of our templates.