3

我正在尝试在 django 应用程序上实现 django-hvad,但在尝试启动时出现错误python manage.py runserver

File "/Users/Philippe/Documents/DjangoApp/env/lib/python3.6/site-packages/hvad/manager.py", line 265, in _clone
    return super(TranslationQueryset, self)._clone(**kwargs)
TypeError: _clone() got an unexpected keyword argument 'shared_model'

我在翻译模型时是否犯了任何错误?谢谢你的帮助!

模型.py

class Opponent(TranslatableModel):
    name = models.CharField(max_length=255, unique=True, null=True)
    companyType = models.ForeignKey(CompanyType, on_delete=models.SET_NULL, blank=True, null=True, related_name='opponents')
    pricing = models.ManyToManyField(Pricing, blank=True)
    translations = TranslatedFields(
        description = models.TextField(null=True, blank=True)
    )

    def __str__(self):
        return "{}" .format(self.name)

    def save(self, *args, **kwargs):
        super(Opponent, self).save(*args, **kwargs)  # Call the "real" save() method.

序列化程序.py

class OpponentSerializer(TranslatableModelSerializer):
    class Meta:
        model = Opponent
        fields = '__all__'

视图.py

class OpponentViewSet(viewsets.ModelViewSet):
    queryset = Opponent.objects.language().all()
    serializer_class = OpponentSerializer

    def get_queryset(self):
        user_language = self.request.GET.get('language')
        return Opponent.objects.language(user_language).all()
4

1 回答 1

1

Django-hvad 与 Django 2 尚不兼容。这是问题所在

于 2018-08-23T21:46:13.700 回答