Re: Why INSERT instead of UPDATE?
On Sun, Nov 7, 2010 at 4:21 PM, Torbjorn
<torbjorn.lundquist@googlemail.com> wrote:
> Hi, I want to update a record but somehow it becomes an INSERT
> instead. This is my code:
>
> def editcourse(request, course_id):
> course= Course.objects.get(id=course_id)
> if request.method == 'POST':
> form = PartialCourseForm(request.POST, instance=course)
> if form.is_valid():
> form.save()
> return HttpResponseRedirect("/courses/")
> else:
> form = PartialCourseForm(instance=course)
>
> return render_to_response("editcourse.html", {'form':form})
>
> What do I wrong?
Can you paste your course model?
--
Marc
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home