[Answered ]-Django ModelForm isn`t saving data

1👍

You can’t have two views with the same URL pattern – you have both bons_list and subscribe at the root URL. This means that only the bons_list view is ever called.

You need to give subscribe its own URL.

(When you do this, you’ll get an error on submit because of the empty template name in the render call; not sure why you are doing that, you need to provide a template to render when the form is not valid. You should also redirect when it is valid; presumably you would redirect back to the home page.)

1👍

Your problem lies here in your urls.py

url(r'^$', views.bons_list, name='bons_list'),
url(r'^(?P<pk>\d+)$', DetailView.as_view(model=Bancnote, template_name='catalogue/bon_detail.html')),
url(r'^feedback/$', views.feedback, name='feedback'),
url(r'^$', views.subscribe_us, name='subscribe')

The way django matches urls it will match the first regex that matches the request. The way your urls.py is written the subscribe view is never called. You will need a different url to post the request to for this to work.

👤Colwin

Leave a comment