TypeError: super(type, obj): obj must be an instance or subtype of type
jekoie opened this issue · 2 comments
jekoie commented
i follow the http://django-contrib-comments.readthedocs.io/en/latest/quickstart.html tutorial to test my django app, but it raise this error???
models.py:
from django.db import models
from django_comments.abstracts import CommentAbstractModel, COMMENT_MAX_LENGTH
class CommentModel(CommentAbstractModel):
comment = models.TextField('评论', max_length=COMMENT_MAX_LENGTH)
forms.py
from django import forms
from django_comments.forms import CommentForm as BaseCommentForm
from comments.models import CommentModel
from django_comments.abstracts import COMMENT_MAX_LENGTH
class CommentForm(BaseCommentForm):
comment = forms.CharField(label='评论', widget=forms.Textarea(attrs={'class': 'form-control'}), max_length=COMMENT_MAX_LENGTH)
def get_comment_create_data(self, **kwargs):
print(self.cleaned_data)
print(type(self))
data = super(CommentModel, self).get_comment_create_data(kwargs)
data['comment'] = self.cleaned_data['comment']
return data
and it raise
File "D:\mysite\comments\forms.py", line 12, in get_comment_create_data
data = super(CommentModel, self).get_comment_create_data(kwargs)
TypeError: super(type, obj): obj must be an instance or subtype of type
anything is good when i follow the tutorial , but except this, can anyone help me???
claudep commented
The ticket system is for reporting bugs, not getting support. (you mistyped CommentModel instead of CommentForm).
jekoie commented
i saw a wrong place.