Addresses issue #628, using reverse() and the newly created helper function reverse_lazy() (found in ietf/utils/lazy.py) to DRY out the code a bit by decoupling the urls from being hardcoded. With this commit idrfc, and ipr modules have been modified to take advantage of the reverse() and reverse_lazy() functions. - Legacy-Id: 2956 Note: SVN reference [2948] has been migrated to Git commit 9399a2e0e8bbfe5c5a16781fd784776cfa31fbac
21 lines
787 B
Python
21 lines
787 B
Python
from django.utils.functional import lazy
|
|
from django.core.urlresolvers import reverse
|
|
|
|
"""
|
|
A lazily evaluated version of `reverse()`_.
|
|
|
|
It is useful for when you need to use a URL reversal before Django's
|
|
URL names map is loaded. Some common cases where this method is necessary are:
|
|
|
|
* in your URL configuration (such as the ``url`` argument for the
|
|
``django.views.generic.simple.redirect_to`` generic view).
|
|
|
|
* providing a reversed URL to a decorator (such as the ``login_url`` argument
|
|
for the ``django.contrib.auth.decorators.permission_required`` decorator).
|
|
|
|
Usually unicode would be preference but str is the right type instead of unicode.
|
|
This is because reverse passes through iri_to_uri which converts it to a string
|
|
"""
|
|
|
|
reverse_lazy = lazy(reverse, str)
|