AllowAny for djangorestframework中的get方法

时间:2018-02-20 12:09:27

标签: django django-rest-framework

我使用django rest框架, 示例代码

class TestApiView(APIView):

    def get(self, request):
        return Response({'text': 'allow any'})

    def post(self, request):
        return Response({'text': 'IsAuthenticated'})

如何使方法GET可供所有人访问,方法POST仅授权

提前谢谢

1 个答案:

答案 0 :(得分:3)

您可以使用javadocs权限类:

library(RColorBrewer)
library(wordcloud2)

mydf = data.frame(word = c("calling", "meeting", "conference", "contract", "negotiation",
                       "email", "friends", "chat", "text", "deal",
                       "business", "promotion", "discount", "users", "family"),
              n = c(20, 12, 4, 8, 10, 43, 33, 5, 47, 28, 12, 9, 50, 31, 22),
              stress = c(23, 30, 15, 40, 35, 15, 30, 18, 10, 5, 29, 38, 45, 8, 3))

color_range_number <- length(unique(mydf$stress))
color <- colorRampPalette(brewer.pal(9,"Blues")[3:7])(color_range_number)[factor(mydf$stress)]

wordcloud2(mydf, color=color)