25๐
โ
As I can see in the code, you are using same URL for both view, so, whenever you hit URL /
, the request goes to first view(IndexView) which probably does not have any post method. Change the URL for article_add
view. Do like this:
app_name = 'myapp'
urlpatterns = [
url(r'^article-add/$', views.article_add, name='article_add'),
url(r'^$', views.IndexView.as_view(), name='index'),
]
You will be able to access view from URL {host_address}/article-add/
๐คruddra
4๐
There is small mistake in your urls.py change your urls.py following way
app_name = 'myapp'
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^article-add/$', views.article_add, name='article_add'),
]
if you are incuded the โmyappโ urls.py in the main project urls.py then in the form in html just put action="{% url 'article_add' %}"
this way also.
๐คCadmus
Source:stackexchange.com