Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!