-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
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
Like/dislike feature #115
base: master
Are you sure you want to change the base?
Like/dislike feature #115
Conversation
803565d
to
617be02
Compare
617be02
to
9dd4384
Compare
This PR is done. |
|
||
@property | ||
def product_id(self): | ||
return str(self.productidgetter(self._instance)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里等价于 return str(self._instance)
应该不是你预期的结果吧?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mozillazg 不是呀 这里是要通过 productidgetter
来拿到 product_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@killpanda 其实我也没看懂. 在productidgetter
里面 直接返回了参数 不就是 @mozillazg 说的意思么
其次 productidgetter
这个方法名字 不是应该用下划线分词的么 比如 product_id_getter
@killpanda 辛苦 |
post = Post.objects.get_or_404(id=id) | ||
if post: | ||
post.likes.delete(current_user.id) | ||
return '', 201 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete 应该也是204
大家看看现在怎么样? |
@killpanda 现在清楚了不少。有一点,likes这个类,我觉得除了add delete方法要操作数据库,是不是还可以在内部维护一个list/set便于直接取用户 |
@halfcrazy 可以举个例子来说说用法吗? |
@killpanda 知乎问题右边的,xxx,xxx关注了本问题 |
@halfcrazy 加了个 |
👍 |
Likes
model