[Fixed]-Django Method Not Allowed (POST)

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

Leave a comment