FAQ
I'm new to Django so hopefully this will be trivial to solve.

I have a table of data I display in a view along with a simple form to add
a new row of data to the table:

def my_data_view(request, data_id):
myData = MyData.objects.get(pk=data_id)
if request.method == 'POST':
myForm = MyForm(request.POST)
else:
myForm = MyForm()
return render_to_response('myapp/mydata.html',
{ 'my_data' : myData,
'my_form' : myForm,},
context_instance=RequestContext(request))


def add_new_row(request, data_id):
myData = MyData.objects.get(pk=data_id)
if request.method == 'POST':
myForm = MyForm(request.POST)
if myForm.is_valid():
# TODO insert new time into DB
return HttpResponseRedirect(reverse('senslog.views.mydata',
args=(myData.id,)))
return my_data_view(request, data_id)

This works when I submit a valid form. However submitting an invalid form
directs me from myapp/mydata/3 to myapp/mydata/addNewRow/3 which means when
I submit the corrected form it posts to myapp/addNewRow/addNewRow/3 which
is obviously not what I want. Any suggestions?

Thanks much!

Kevin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/X0x91sUiuzoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdjango-users @
categoriesdjango, python
postedJul 13, '12 at 7:56p
activeJul 13, '12 at 7:56p
posts1
users1
websitedjangoproject.com

1 user in discussion

Kevin: 1 post

People

Translate

site design / logo © 2022 Grokbase