Thursday, September 29, 2011

Re: Help with forms (really struggling)

Thank you both for your assistance.

When I try to use the following (which is my interpretation Tom of
your modifications) I get this error:

Cannot assign "u'1'": "Log.person" must be a "Person" instance.

@login_required
@transaction.commit_on_success
def update_log(request, pk):
if request.method == 'POST':
form = LogForm(request.POST, prefix='log')
if form.is_valid():
log = form.save(commit=False)
log.person = pk
log.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")

--
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