I am on the exact same situation as the one described in the documentation 
here: 
https://docs.djangoproject.com/en/1.7/topics/class-based-views/mixins/#using-formmixin-with-detailview
 

I have followed the documentation but I get the following exception:

__init__() takes exactly 1 argument (3 given)

Request Method:GETRequest 
URL:http://localhost:8000/post/5144752345317376/Django 
Version:1.6.11Exception Type:TypeErrorException Value:

__init__() takes exactly 1 argument (3 given)

Exception Location:...app/sitepackages/django/core/handlers/base.py in 
get_response, line 11



I think the only location where I might need something different is my 
urls.py... Here is the complete code:


class PostView(BlogMixin,DetailView):
    """ A view for displaying a single post """
    template_name = 'post.html'
    model = Post
    def get_context_data(self, **kwargs):
        context = super(PostView, self).get_context_data(**kwargs)
        context['form'] = CommentForm()
        return context
    
class PostDetailView(View):
    print "HERE   ------------ "


    def get(self, request, *args, **kwargs):
        print "GET   ------------ "
        view = PostView.as_view()
        return view(request, *args, **kwargs)


    def post(self, request, *args, **kwargs):
        print "POST   ------------ "
        view = PostComment.as_view()
        return view(request, *args, **kwargs)


class PostComment(  SingleObjectMixin , FormView):
    template_name = 'post.html'
    form_class = CommentForm
    model = Post


    def post(self, request, *args, **kwargs):
        self.object = self.get_object()
        return super(PostComment, self).post(request, *args, **kwargs)


    def get_success_url(self):
        return reverse('post-detail', kwargs={'pk': self.object.pk})

class BlogMixin(object):
    """
    Basic mixin for all the views. Update the context with additional
    information that is required across the whole site, typically
    to render base.html properly
    """
    def get_context_data(self, *args, **kwargs):
        context = super(BlogMixin, self).get_context_data(*args, **kwargs)
        blog = Blog.get_unique()
        context.update({
            'blog': blog,
            'active_user': users.get_current_user(),
            'is_admin': users.is_current_user_admin()
        })
        return context

urls.py:
    url(r'^post/(?P<pk>[\d]+)/$', views.PostDetailView., 
name="post-detail"),



Before the exception, 'HERE ------" is printed, but no GET or POST

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/299d4e5e-0b69-4627-a1e6-e7f2d1ff9d8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to