Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9307689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:26:53+00:00 2026-06-19T00:26:53+00:00

There is one last thing I’m a little confused on with Django Rest Framework

  • 0

There is one last thing I’m a little confused on with Django Rest Framework and that’s the different between permission classes and authentication classes.

this is my settings.py

REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
    'rest_framework.permissions.IsAdminUser',


),
'DEFAULT_AUTHENTICATION_CLASSES': (
    'rest_framework.authentication.TokenAuthentication',
    'rest_framework.authentication.SessionAuthentication',
),
'PAGINATE_BY': 10

}

and in my view I have the following…

class ProfileList(generics.ListCreateAPIView):
    """
    API endpoint that represents a list of users.
    """
    permission_classes = (permissions.IsAdminUser,)
    model = Profile
    serializer_class = ProfileSerializer

    def pre_save(self, obj):
        obj.owner = self.request.user

What I assumed would happen with above is that only admin users had access to the browserable API while still a user with a valid token could get the json request. However, this is not the case only is IsAuthenticated seems to give them access but = this and still allows my users access to the online version when logged in.

I want all my users with a valid token to get access, but only admin users to have permission to view the online API version with sessions, is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:26:54+00:00Added an answer on June 19, 2026 at 12:26 am

    I want all my users with a valid token to get access, but only admin users to have permission to view the online API version with sessions, is this possible?

    The first thing worth noting is that the browseable API won’t give your users any more permissions than they would having if you only render to JSON. It’s just a much nicer view onto the API endpoints. Personally I would typically want to expose the browseable API to end-developers as it makes developing against the API easier.

    If you really do want to hide it from everyone except admin users here are two approaches you could take:

    1. Override the get_renderers() method on the view. (Briefly documented here)
      You can check self.request.user.is_staff, and only include the Browseable API renderer if it’s an admin user.

    2. Subclass the browseable API renderer, and override .render(). (Eg see here) You can get the incoming request using renderer_context['request'], and simply render to standard JSON if it’s not an admin user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there one method or property in the .NET Framework that tells if an
There's one specific feature that I wish was in the .NET framework, but isn't.
As a follow up question to my last one , is there any simple
I have a css drop down menu working except for one thing: the last
I'm looking for a standard dual-map structure - is there one implemented in std/boost/another
Network file systems are offered by Windows and (L)Unix. Is there one for IBM
There is one table. Parent_id references same table id. How insert raw if parent_id
There is one client who cannot see the img title tags in IE8. Is
there is one variable var=581 we need to copy the value of this variable
There is one form, inside the form there are many checkboxes. Two operations can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.