django_comments TypeError:super(type,obj):obj必须是类型的实例或子类型

时间:2018-07-27 09:04:39

标签: django-comments

我按照http://django-contrib-comments.readthedocs.io/en/latest/quickstart.html教程测试了我的django应用,但这会引发此错误??

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

它提高了

get_comment_create_data中第12行的文件“ D:\ mysite \ comments \ forms.py”     数据=超级(CommentModel,self).get_comment_create_data(kwargs) TypeError:super(type,obj):obj必须是类型的实例或子类型

当我按照本教程进行操作时,一切都很好,但是除此之外,任何人都可以帮助我吗?

0 个答案:

没有答案
相关问题