-1

I'm trying to change the url of http://localhost:8000/stories-and-literature/fairy-tales/ to http://localhost:8000/stories-and-literature/classic-literature/, and I'm not to sure how I can change it in my urls.py. So far, I have this code in urls.py:

from django.conf.urls import patterns, url

from topictree import views

urlpatterns = patterns('',
    (r'^$', 'topictree.views.index'),
    (r'^(?P<slug>\D+)/$', 'topictree.views.tree')
)

I want to change the slug of url from "fairy-tales" to "classic-literature" because I want to present the url like a tree. In this case, both "fairy-tales" and "classic-literature" are children of "story-and-literature", so when I click on the "fairy-tales" link and then click on the "classic-literature" link, the "fairy-tales" slug should be removed, and be replaced by the "classic-literature" slug.

I was thinking of changing the url in views.py instead of urls.py since views.py contains the control flow of the program. Is it possible to change the url in views.py instead of urls.py?

Any help would be much appreciated.

Lino
  • 229
  • 4
  • 12

1 Answers1

0

Foo Bar User's link is a good place to start but judging by your question I would say you should go straight to the Django Docs

https://docs.djangoproject.com/en/1.6/topics/http/urls/

That should get you back on your feet. :)

applewood
  • 371
  • 2
  • 10