Url configuration in django always executs the same view -
i want achieve following behavior
- http://localhost/ runs index view in app
- http://localhost/myview runs myview in app
so in main urls.py have following setup
urlpatterns = [ url(r"^", include("myapp.urls")), url(r"^admin/", include(admin.urls)), ]
and in myapp urls.py
urlpatterns = [ url(r'$', "myapp.views.index"), url(r'myview/$', "myapp.views.myview") ]
but both links execute index view , myview gets never executed. missing something?
you should add ^
start of app url patterns:
urlpatterns = [ url(r'^$', "myapp.views.index"), url(r'^myview/$', "myapp.views.myview") ]
Comments
Post a Comment