Changeset 6205
- Timestamp:
- Aug 15, 2008, 10:28:40 PM (16 years ago)
- Location:
- exodus
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
exodus/templates/addlocation.html
r6183 r6205 6 6 7 7 <form method="post" action="."> 8 <p> 9 <label for="id_description">Description:</label> {{ form.description }} 10 {% if form.description.errors %}*** {{ form.description.errors|join:", " }}{% endif %} 11 </p> 12 <p> 13 <label for="id_coordinateX">X coordinate:</label> {{ form.coordinateX }} 14 {% if form.coordinateX.errors %}*** {{ form.coordinateX.errors|join:", " }}{% endif %} 15 </p> 16 <p> 17 <label for="id_coordinateY">Y coordinate:</label> {{ form.coordinateY }} 18 {% if form.coordinateY.errors %}*** {{ form.coordinateY.errors|join:", " }}{% endif %} 19 </p> 20 21 <input type="submit" value="sumbit" /> 8 <table>{{ form.as_table }}</table> 9 <input type="submit" value="submit"> 22 10 </form> 23 11 -
exodus/views.py
r6204 r6205 11 11 from exodus.wllogic import freemasterip, newssidname 12 12 13 class AddLocationForm(forms.ModelForm): 14 class Meta: 15 model = Location 16 13 17 def addlocation(request): 14 manipulator = Location.AddManipulator() 15 16 17 if request.POST: 18 new_data = request.POST.copy() 19 20 for data in new_data: 21 print "%s" % len(new_data) 22 23 print "%s" % new_data['description'] 24 25 errors = manipulator.get_validation_errors(new_data) 26 27 if not errors: 28 manipulator.do_html2python(new_data) 29 new_place = manipulator.save(new_data) 30 31 return HttpResponseRedirect("/exodus/") 32 33 else: 34 errors = new_data = {} 35 36 form = forms.FormWrapper(manipulator, new_data, errors) 37 return render_to_response('addlocation.html', {'form': form, 'new_data': new_data}) 18 if request.POST: 19 form = AddLocationForm(request.POST) 20 if form.is_valid(): 21 form.save() 22 return HttpResponseRedirect("/exodus/") 23 else: 24 form = AddLocationForm() 25 return render_to_response('addlocation.html', {'form': form }) 38 26 39 27 class AddNodeForm(forms.ModelForm):
Note:
See TracChangeset
for help on using the changeset viewer.