Skip to content

Instantly share code, notes, and snippets.

@mishudark
Created October 6, 2012 17:54
Show Gist options
  • Save mishudark/3845615 to your computer and use it in GitHub Desktop.
Save mishudark/3845615 to your computer and use it in GitHub Desktop.
Django Dynamic Urls
# urls.py
urlpatterns += patterns('',
(r'^(?P<page_alias>.+?)/$', 'views.static_page'),
)
# views.py
def static_page(request, page_alias): # page_alias holds the part of the url
try:
active = Page.objects.get(page_alias=page_alias)
except Page.DoesNotExist:
raise Http404("Page does not exist")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment