Tuesday, July 28, 2015

Re: Using FormMixin with DetailView

The override is this, I was experimenting with save..


class CommentForm(forms.ModelForm):
   
class Meta:
        model
= Comment
        exclude
= ("parent_post","created_at")


    def create_view(request, **kwargs):
        print "IN VIEW"
       
if request.method == "POST":
            parent_fk
= self.object
           
print "PARRENT"
           
print parent_fk
            form
= CommentForm(request.POST)
           
if form.is_valid():
                new_comment
= form.save(commit=False)
                new_comment
.parent_post = parent_fk
                new_comment
.save()
               
return HttpResponseRedirect(request.META.get('HTTP_REFERER'))


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6825b838-584c-4e89-bc4e-4a6d0bf81c5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment