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 6698561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:35:32+00:00 2026-05-26T06:35:32+00:00

I have several admin instances running on a site – one for each country,

  • 0

I have several admin instances running on a site – one for each country, that the site supports.

However, if a user logs into one admin, they are automatically able to access other instances.

I need to make the auth code aware of which admin the user has logged into and prevent access to other admin systems.

Any ideas how this can be done?

  • 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-05-26T06:35:33+00:00Added an answer on May 26, 2026 at 6:35 am

    You can use middleware to check for user permissions to access certain areas of admin site. Checkout this snippet. (You might want to know more about handling custom permissions in Django.)

    If you need something more universal, you can use the code example below. The idea is simple: it uses custom functions to find out about user permissions and to give an appropriate response:

    #coding: utf-8
    # Note that RESTRICTED_URLS tuple takes three parameters: url regex, function to check
    # whether user has certain permission, and a function to redirect the user to a certain 
    # page if he doesn't have sufficient rights.
    import re
    from django.core.urlresolvers import reverse
    from django.utils.translation import ugettext_lazy as _
    from django.http import HttpResponseRedirect
    from django.contrib import messages
    from backend.models import Professional
    from django.contrib.auth.decorators import permission_required
    
    def calculate_forbidden_response(request, view_func,view_args,view_kwargs):
        if not request.user.is_authenticated():
            return permission_required('')(view_func)(request,*view_args,**view_kwargs)
        elif request.user.has_perm('backend.p_add_professional'):
            messages.error(request, _('You need permission Spam to enter this cabinet.'))
            return HttpResponseRedirect('/some_help_page_about_permissions.html')
    
    def check_professional_permission(request):
        return request.user.has_perm('backend.p_access_professional_cabinet')
    
    RESTRICTED_URLS = (
                        (r'/professional/(.*)$', check_professional_permission, calculate_forbidden_response),
                      )
    RESTRICTED_URLS_EXCEPTIONS = ()
    
    class CheckPermissionMiddleware(object):
        def __init__(self):
            self.restricted = tuple([(re.compile(url[0]), url[1], url[2]) for url in RESTRICTED_URLS])
            self.exceptions = tuple([re.compile(url) for url in RESTRICTED_URLS_EXCEPTIONS])
    
        def process_view(self,request,view_func,view_args,view_kwargs):
            if request.user.is_superuser:
                return None
            for path in self.exceptions:
                if path.match(request.path): return None
            for rule in self.restricted:
                url, permission = rule[0], rule[1]
                calculated_response = rule[2]
                if url.match(request.path):
                    if not permission(request):
                        return calculated_response(request, view_func,view_args,view_kwargs)
                    else:
                        return None
            return None
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model Question which can have several Answer instances, each one with
I am creating an admin menu for a site and I have several drop
I have several Customer s who book Appointment s. Each Appointment has exactly one
I'm beginning work on a web application that will have several distinct user types,
I have several strings in my site that don't belong to any app, for
I have a module that creates several admin/settings/modname pages. I created a new role.
I have several Jenkins parameterized jobs that uses the same parameters and parameters values.
I have several RequiredFieldValidators in an ASP.NET 1.1 web application that are firing on
We have several jobs that run concurrently that have to use the same config
I have several old 3.5in floppy disks that I would like to backup. My

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.