Url configuration in django always executs the same view -


i want achieve following behavior

  1. http://localhost/ runs index view in app
  2. 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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -