Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

271
Visualizações
AssertionError: Cannot apply DjangoModelPermissionsOrAnonReadOnly

I have a problem with (I think) permissions. When I try to send post request via postman, I get following error:

AssertionError: Cannot apply DjangoModelPermissionsOrAnonReadOnly on a view that does not set .queryset or have a .get_queryset() method. [29/Nov/2021 20:21:21] "POST /api/blog/category HTTP/1.1" 500 101581

Here are my views.py and category class. Also, I noticed that for some reason in def post(self, request, format=None) request is not being called ("request" is not accessed Pylance). I think the problem is somewhere here, but can't figure it out. Thank you in advance.

class BlogPostCategoryView(APIView):
    serializer_class = BlogPostSerializer
    permissions_classes = (permissions.AllowAny, )

    def post(self, request, format=None):
       data = self.request.data
       category = data['category']
       queryset = BlogPost.objects.order_by('-date_created').filter(category__iexact=category)

       serializer = BlogPostSerializer(queryset, many=True)

       return Response(serializer.data)
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

In settings.py you can add:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.BasicAuthentication',
    ]
}

Then in postman go to the Authorization tab and for type select Basic Auth. You can then enter your username and password. You should be able to make Post requests after this.

enter image description here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda