That's what I also figured. I began trying to pass content_type and object_id as hidden fields to the view. This didn't work (see code below), so I'm going to try to use the content_type as a part of the url. But perhaps you can explain why I can't use it in the form object?
views.vote: def vote2(request): if request.method == 'POST': form = VoteForm(request.POST) if form.is_valid(): new_vote = form.save(commit=False) #This returns ValueError: Cannot assign "u'12'": "Vote.content_type" must be a "ContentType" instance. new_vote.content_type = ContentType.objects.get_for_id(form.cleaned_data['content_type']) #This SHOULD work, right? new_vote.save() return HttpResponseRedirect('/news/1/') #To make dynamic once the above code work Thanks, /Martin On May 13, 8:14 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: > On May 13, 6:11 pm, marty3d <martin.kjellb...@gmail.com> wrote: > > > Thanks, that's a shame... > > So I'm now trying to do the request.POST stuff in a view instead. > > Since the idea is to have the voting app as decoupled as possible, is > > there a slick way to pass, perhaps the whole object in this case, but > > at least the name of the model or similar together with the post? > > > Thanks! > > /Martin > > So presumably this form appears, via the template tag, on a range of > pages, and you want to record in the voting model which page it came > from. > > One way of doing this would be to set the form's action - ie the > destination it POSTs to - to a URL that includes parameters > representing the source page - eg /vote/sourcemodel/sourceid/. Then > the destination view can accept this information and save it alongside > the vote. > -- > DR. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.