python - django how to place variable in a raw string,such as for URL router -
python - django how to place variable in a raw string,such as for URL router -
i want write url configured when needed,for example:
url(r'^api/v1/books/',include('article.urls')) in settings.py set apiversion = 'api/v1'
i want set apiversion url create configureable,how that,is there best way accomplish that?
in urls.py:
from django.conf import settings urlpattern = patterns('', url(settings.apiversion, include( url(r'/books/',include('article.urls'), ) ) in settings.py:
apiversion = r'^api/v1' you can avoid nested include using variable.
python django django-urls
Comments
Post a Comment