Hello,
could you show us the relevant part of your urls.py file? I suspect view parameters to cause the trouble but I'd like to be sure.
Best,
Gergely
On 28 Jul 2015 00:46, "Ioannis Latousakis" <latusaki@gmail.com> wrote:
-- 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)I think the only location where I might need something different is my urls.py... Here is the complete code:
Request Method: GET Request URL: http://localhost:8000/post/5144752345317376/ Django Version: 1.6.11 Exception Type: TypeError Exception Value: __init__() takes exactly 1 argument (3 given)Exception Location: ...app/sitepackages/django/core/handlers/base.py in get_response, line 11
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 additionalinformation that is required across the whole site, typicallyto 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 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/299d4e5e-0b69-4627-a1e6-e7f2d1ff9d8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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/CACczBUL-Kog-%3D04Biv3uKpE8_qNMNt_GxzFH%3Doa_DNMtRxm83g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment