Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

270
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda