Reputation: 11
When I click on submit button is shows me this error:
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^admin/
^home/$
^insert/$ [name='insert']
The current path, home/insert, didn't match any of these.
views.py:
def insert_page(request):
name1 = request.GET['NAME']
email1 = request.GET['EMAIL']
message1 = request.GET['MSG']
data = Feedback(name = name1,email = email1 , message =message1)
data.save()
return HttpResponse("<html><body bgcolor = cyan> Thanks For Feedback </body></html>")
index.html
<form action="./insert" method="get">
<div class="row">
<div class="col-md-6 col-sm-6">
<div class="form-group">
<input type="text" class="form-control" required="required" placeholder="Name" name="NAME">
</div>
</div>
<div class="col-md-6 col-sm-6">
<div class="form-group">
<input type="text" class="form-control" required="required" placeholder="Email address" name = "EMAIL">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-sm-12">
<div class="form-group">
<textarea name="message" id="message" required="required" class="form-control" rows="3" placeholder="Message" name = "MSG" ></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default">Submit Request</button>
</div>
</div>
</div>
</form>
urls.py
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^home/$',index_page),
url(r'^insert/$',views.insert_page,name = 'insert'),
]
Upvotes: 0
Views: 67
Reputation: 9318
I reckon the method is supposed to be POST
here. But if you want to try GET
on dev - it's ok.
<form action="./insert" method="get">
and the URL must be "/insert"
<form action="/insert" method="post">
starting with /
means - under the root page, starting with ./
means - under current page's URL.
If this is what you want then you must handle url(r'^home/insert/', ...
instead of url('^insert/')
. If not - fix URL in form's action
attribute.
Upvotes: 1
Reputation: 1234
i think you missed views.index_page
for url(r'^home/$',index_page),
Upvotes: 0