django - HTML variable inside of String -


i'm building website django. want have string url [already done], want string changeable based on variables.

sudocode: variable = "hello"

url = "www.facebook.com/a" ----> want "a" changeable, if changes, url goes different website.

what best way this?

thanks

you should use saving groups in urls.py:

from django.conf.urls import patterns, url  urlpatterns = patterns('',     url(r'^(?p<part>\w*)/$', 'my_app.views.my_view'), ) 

then, in my_view view string appear keyword argument:

def my_view(request, part=none):     print part 

hope helps.


Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -