我已经尝试过逆转DRF了吗
from rest_framework.reverse import reverse
reverse("posts-api:article_year_month",args=(2017,1))
'/api/gaurnitai/posts/2017/1'
而reverse_lazy不起作用:
from rest_framework.reverse_lazy import reverse_lazy
reverse_lazy("posts-api:article_year_month",args=(2017,1),request=request)
ModuleNotFoundError: No module named 'rest_framework.reverse_lazy'
答案 0 :(得分:1)
您的导入应该是
from rest_framework.reverse import reverse_lazy