7👍
✅
Ok I think maybe I spotted the problem. The view
is not executing because you have defined three urls with the exact regex
in your project urls.py
:
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^$', views.register, name='register'),
url(r'^$', views.projectz_save, name='project_save'),
)
Django match it’s urls by iterating over the patterns in the way they appeared so in that file all urls will match index
. That’s probably the reason why the page appears to be refreshing. Try to modify this a little:
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^register$', views.register, name='register'),
url(r'^save$', views.projectz_save, name='project_save'),
)
This way you can execute the projectz_save
method in the views.py
if the action
of the form matches the url regex.
Hope this helps!
Source:stackexchange.com