We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关注和屏蔽操作不可少。本 issue 主要关注于用户之间的互相关注与 blocked. 这是一个多对多的操作。
一个用户对另一个用户的关联,主要就是“关注”或“屏蔽”。 使用一个枚举的表示这两种关系。
class UserRelationState(IntEnum): FOLLOWING = 1 # 关注 BLOCKING = 4 # 屏蔽 @property def label(self): return _user_relation_state_to_text[self] _user_relation_state_to_text = { UserRelationState.FOLLOWING: "关注", UserRelationState.BLOCKING: "屏蔽" }
在这个多对多的关系中,关注和屏蔽其实是互斥的,所以可以记录在同一条记录上。
class UserRelation(BaseModel): from_user = models.ForeignKey(WepostUser,on_delete=models.CASCADE,verbose_name="用户") to_user = models.ForeignKey(WepostUser,on_delete=models.CASCADE, verbose_name="目标用户") state = models.PositiveSmallIntegerField("状态", choices=UserRelationState.choices()) class Meta: unique_together = ("from_user", "to_user") verbose_name = "关注与屏蔽" verbose_name_plural = verbose_name
由于同一个用户对另一个用户只维护一个关注,所以这里使用复合的索引 ,通过限定 from_user,to_user 的维护性,也是隐式的告诉数据库这里需要索引。
from_user
to_user
The text was updated successfully, but these errors were encountered:
No branches or pull requests
关注和屏蔽操作不可少。本 issue 主要关注于用户之间的互相关注与 blocked.
这是一个多对多的操作。
一个用户对另一个用户的关联,主要就是“关注”或“屏蔽”。
使用一个枚举的表示这两种关系。
在这个多对多的关系中,关注和屏蔽其实是互斥的,所以可以记录在同一条记录上。
由于同一个用户对另一个用户只维护一个关注,所以这里使用复合的索引 ,通过限定
from_user
,to_user
的维护性,也是隐式的告诉数据库这里需要索引。The text was updated successfully, but these errors were encountered: