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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:18:18+00:00 2026-06-05T02:18:18+00:00

My current project involves a legacy codebase which makes use of Django’s models in

  • 0

My current project involves a legacy codebase which makes use of Django’s models in a limited way; syncdb isn’t being used (i.e., the model is not Django-managed). I need to restrict access to certain columns based on permissions (i.e. a view_all permission will show all of the columns, while no permission will restrict the user to a few basic columns). This permission will apply to different tables.

The way I am thinking of doing this is to simply use SQL to insert a new auth_permission. However, this is complicated by the content_type_id column: my understanding is that a content type applies to one model, and this (as I said) will need to apply to different tables, and I can’t reliably run syncdb.

Has anyone else implemented something along these lines? Did you use the Django infrastructure, or did you end up using a separate table for safety? Did you implement this at the signal level, or at each point where the model is used?

Thanks!

  • 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-05T02:18:20+00:00Added an answer on June 5, 2026 at 2:18 am

    It sounds to me like you are actually looking for permission groups. They can be easily created model independently. The user groups wouldn’t need to contain any actual permissions.

    You can check if a user is in a specific group:

    def user_in_group(user, group_name):
        return user.groups.filter(name=group_name).count()
    

    You could use it like this:

    def my_view(request):
        if user_in_group(request.user, 'view_all'):
            # do the things
        else:
            # do the other things
    
    # limit this view to 'view_all' users
    @user_passes_test(lambda u: user_in_group(u, 'view_all'))
    def my_other_view(request):
        # and do some more things
    

    I don’t know what you mean with

    Did you implement this at the signal level, or at each point where the
    model is used?

    Obviously with any authorization method you would need to insert checks wherever a model is viewed and insert logic to show only the permitted columns (like rendering a subset of columns in a template).

    To make sure that no wrong columns are accessed you could write proxy classes that limit access to the apropriate fields/columns and use proxy instances instead of model instances.

    class SomeModelProxy(object):
        def __init__(self, model_instance, user):
            self.instance = model_instance
            self.user = user
    
        def save(self, *args, **kwargs):
            self.instance.save(*args, **kwargs)
    
        # define other methods that are needed...
    
        def __getattr__(self, name):
            if not name in get_allowed_columns_for_user_somehow(self.user):
                raise AttributeError
    
            return getattr(self.instance, name)
    
        def __setattr__(self, name, value):
            if not name in get_allowed_columns_for_user_somehow(self.user):
                raise AttributeError
    
            setattr(self.instance, name, value)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My current project for work involves developing a SharePoint 2007 WebPart which will be
My current project involves using LDAP (Active Directory) and I'm using issue tracking for
My team's current project involves re-writing retrieval libraries in JavaScript. We are basically looking
My current project requires a customized System date, which means a system date and
On a current project I'm using a helper class to make API calls, which
I am working on a project which basically involves parsing and storing information about
I got a project using GWTP (which involves MVP separation, Gin and Dispatch), now
I have a little Android project going on which involves some IPC where client
In my current project there is a Form class which looks like this: public
My current project involves deploying an upgraded .exe file that runs as a Windows

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.