Thursday, September 29, 2011

Re: Help with forms (really struggling)

Hi Kurtis

Thanks for your reply.

That wasn't a silly question. A person is not a user.

I modified my view like this:

@login_required
def update_log(request, pk):
try:
person = Person.objects.get(pk=pk)
except KeyError:
raise Http404
if request.method == 'POST':
form = LogForm(request.POST, instance=person,
prefix='log')
if form.is_valid():
form.save()
response_dict = {}
response_dict.update({'success': True})
return HttpResponse(json.dumps(response_dict),
mimetype="application/json")
else:
return HttpResponse(json.dumps(form.errors),
mimetype="application/json")

When submitting the form I get back a json response saying success,
but the form data is not saved into the database. Am I doing something
silly?

Thanks again

--
You received this message because you are subscribed to the Google Groups "Django users" group.
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.

No comments:

Post a Comment