| 1684 | The ``permalink()`` decorator |
| 1685 | ----------------------------- |
| 1686 | |
| 1687 | The trouble with the use of ``get_absolute_url()`` above is that hard coding |
| 1688 | parts of your urls couples URLs to models, which violates the DRY principle, |
| 1689 | because URLs are defined both in a URLconf and in the model. |
| 1690 | |
| 1691 | In the development version, you can further decouple your apps using the |
| 1692 | ``permalink`` decorator. for example:: |
| 1693 | |
| 1694 | from django.db.models import permalink |
| 1695 | |
| 1696 | def get_absolute_url(self): |
| 1697 | return ('people.views.detail', str(self.id)) |
| 1698 | get_absolute_url=permalink(get_absolute_url) |
| 1699 | |
| 1700 | The decorated function does a reverse lookup to calculate the url for the |
| 1701 | object based on view and parameters returned by the undecorated function, and |
| 1702 | your project / apps' urlconfs. |
| 1703 | |
| 1704 | |