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

  • Home
  • SEARCH
  • 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 400585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:57:17+00:00 2026-05-12T16:57:17+00:00

I’m looking for some input on how others would architect this. I’m going to

  • 0

I’m looking for some input on how others would architect this. I’m going to provide class (django group) based views.

For example, a user’s group will determine what views/templates he or she will have access to. I’m thinking of perhaps storing paths to view functions in a table to determine what a user’s link bar will consist of. Filter specifications can also be stored to determine what rows will fill these templates.

A good example is a hospital nursing units. Nurses at one unit need not see the entire hospital’s patients. They only need to see their patients. Doctors on the same unit need only to see those patients as well, but they should have access to much greater functionality.

Has this been done via some third party application? And how would you approach this problem?

Thanks,
Pete

  • 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-12T16:57:18+00:00Added an answer on May 12, 2026 at 4:57 pm

    Django already has a groups and permissions system, which may be sufficient for your purpose.

    http://docs.djangoproject.com/en/dev/topics/auth/

    Generally in your code you check if a user has a permission. A user has his own permissions and those of the groups he belongs to. You can administer this pretty easily from the admin console.

    There are two parts you need to look at.

    1. Check that a user requesting a page
      has permission to do so.
    2. Only display links to the user if he
      has the permission.

    For 1. you can check permissions in a decorator as such:

    from django.contrib.auth.decorators import permission_required
    
    @permission_required('polls.can_vote')
    def some_view(request):
    

    For 2. the currently logged-in user’s permissions are stored in the template variable {{ perms }}. This code checks the same permission as above.

    {% if perms.polls.can_vote %}
        <a href="/vote">vote</a>
    {% endif %}
    

    To generate a list of links you can iterate over user.get_all_permissions() and fetch the links (or function that generates the link) from a dict:

    def more_elaborate_list_of_links_for_a_perm(user):
        return ["/link1", ...]
    
    _LINKS = {
        'polls.can_vote' : lambda u: ["/user/specific/link/" + u.id],
        'polls.can_close': lambda u: ['/static/link/1', 'static/link/2'],
        'polls.can_open' : more_elaborate_list_of_links_for_a_perm
    }
    
    def gen_links(user):
        # get_all_permissions also gets permissions for users groups
        perms = user.get_all_permissions()
        return sum((_LINKS[p](user) for p in perms if p in _LINKS), [])
    

    There are probably many other approaches.

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

Sidebar

Related Questions

No related questions found

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.