如何禁用DjangoActivityStream的跟踪功能

2024-04-19 13:12:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用django-activity-stream创建一个Django应用程序。我已经在项目中注册了应用程序。不幸的是,应用程序的内置follower/following特性与我的following table冲突-我想要比库允许的更细粒度的控制。有人知道如何禁用该功能或回避这个问题吗?你知道吗

ERRORS:
actstream.Follow.content_type: (fields.E304) Reverse accessor for 'Follow.content_type' clashes with reverse accessor for 'Follow.content_type'.
    HINT: Add or change a related_name argument to the definition for 'Follow.content_type' or 'Follow.content_type'.
actstream.Follow.user: (fields.E304) Reverse accessor for 'Follow.user' clashes with reverse accessor for 'Follow.user'.
    HINT: Add or change a related_name argument to the definition for 'Follow.user' or 'Follow.user'.
content.Follow.content_type: (fields.E304) Reverse accessor for 'Follow.content_type' clashes with reverse accessor for 'Follow.content_type'.
    HINT: Add or change a related_name argument to the definition for 'Follow.content_type' or 'Follow.content_type'.
content.Follow.user: (fields.E304) Reverse accessor for 'Follow.user' clashes with reverse accessor for 'Follow.user'.
    HINT: Add or change a related_name argument to the definition for 'Follow.user' or 'Follow.user'.

遵循模型:

class Follow(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey()

Tags: orfieldsformodelstypewithcontentreverse
1条回答
网友
1楼 · 发布于 2024-04-19 13:12:40

尝试向模型字段添加相关的名称:

class Follow(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE,
                     related_name='my_follow_user')
    content_type = models.ForeignKey(ContentType,  
                     on_delete=models.CASCADE,
                     related_name='my_follow_content_type')
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey()

或者类似的东西。你知道吗

Django型号参考:

https://docs.djangoproject.com/en/2.0/ref/models/fields/

相关问题 更多 >