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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -