Skip to content
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

浏览量 #37

Open
Sube-py opened this issue Aug 6, 2022 · 1 comment
Open

浏览量 #37

Sube-py opened this issue Aug 6, 2022 · 1 comment

Comments

@Sube-py
Copy link

Sube-py commented Aug 6, 2022

浏览量写在哪呀 只看到教程里有 但是代码里没有哎。 不清楚怎么用viewset写自定义逻辑😭

@Sube-py
Copy link
Author

Sube-py commented Aug 6, 2022

view_count = serializers.SerializerMethodField()

def get_view_count(self, obj):
    print("sube")
    obj.view_count += 1
    obj.save()
    return obj.view_count

为什么执行了4次😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant