python - Django Form Submission Failing -


I am working on a small app that will save specific location information about the places you have made The problem I am experiencing is that clicking on the submit button does not seem too much on the 'Save New Location' page. This ... / locationlib / savenew /, which is considered URL which saves form input as a new model object, but both debugging according to the print statement and what really happens, never said that function goes. I have had success with other forms using the Django but this one I think is dripping. Can someone give me an idea about what is going on here?

  def New (requested): return render (request, 'locationlib / new.html') DEF savenew (request): printed 'savenew name' Name = request POST ['name'] Latitude = float (Request. POST ['latitude']) Longitude = Float (Request. POST ['longitude']) = print 'all variable sets' l = location (name = name, longitude = Longitude, Latitude =============================================== =============================================== PRINT L defined 'l.save () print' l saved 'returns httprespps point redirect (reverse (' locationlib: detail ', args = [l.id]))  

new.html

  & lt; div id = 'new-location-form' & gt; form action = "{% url 'locationlib: savenew'%}" method = "post" & gt; {% Csrf_token%} Name: & lt; Input publ R = 'text' name = 'name' value = 'place name' required & gt; & lt; br & gt; User: & lt; input type = 'text' name = 'user' value = 'user' requirement & Lt; br & gt; Longitude: Input type = 'text' name = 'longitude' value = "longitude coordinate" required & gt; & lt; br & gt; Latitude: & lt; input type = 'Text' name = 'latitude' value = 'latitude coordinates' required & gt; & Lt; Br> Details: & lt; Textarea name = 'description' & gt; Place details & lt; / Textarea & gt; & Lt; Br> & Lt; Input type = "submit" value = "save" & gt; & Lt; / Form & gt; & Lt; / Div & gt;  

urls.py

  urlpatterns = pattern ('', ... url (r'new / ', views.new, name =' new '), Url (r' ^ savenew / ', views.savenew, name =' savenew '),  

Your first URL pattern, new, is not anchor to the beginning of the string. This means that it matches anything that "emits" with ends - and it includes "seneway" then your request for "savenew" be caught by that pattern , And being sent to the new scene.

Just put a ^ character in front of you, as you have done other patterns.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -