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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:51:51+00:00 2026-05-20T03:51:51+00:00

we are using django to develop a customer-management application, and we need to set

  • 0

we are using django to develop a customer-management application, and we need to set permissions to an agent whether he/she can edit the customer’s attributes ().

for example,

if i have a model:

class Customer(models.Model):
    # basic information
    name = models.CharField(max_length=150) # the name of this customer
    date = models.DateField(auto_now_add=True) # the date that this customer is created

    # personal information
    citizen_id = models.BigIntegerField(blank=True)
    phone = models.BigIntegerField(max_length=20, blank=True)
    work = models.CharField(max_length=100, blank=True)
    address = models.CharField(max_length=300, blank=True)
    bank_card = models.BigIntegerField()

    # installation detail 
    primary = models.IntegerField(default=0)
    secondary = models.IntegerField(default=0)
    region = models.ForeignKey(Region) # the region that this customer currently lives in
    type = models.ForeignKey(Type) # the installation type
    group = models.ForeignKey(Group)

    STATUS_CHOICES = (
                  ('Active', 'Active'),
                  ('Inactive', 'Inactive'),
                  ('Transfered', 'Transfered'),
                  ('Closed', 'Closed'),
                  ('Suspended', 'Suspended'),
                  ('Cancelled', 'Cancelled'),
                  )

    status = models.CharField(max_length=40, choices=STATUS_CHOICES)

and I want to be able to set the permissions for editing some of the fields, but the current permission system only allow you add/change/delete a model instance, where the “change” allows an user to edit all the attributes in that model, which is not what we really want.

user A can edit phone, address, work and citizen_id
user B can only edit phone and address,
user C can edit citizen_id, …..
etc…

and I want to be able to set different permissions

Is it possible to make this happen? It’d be really helpful if I could use the django admin system to manage agents and customers.

=======================
thank you so much for FallenAngel’s reply.

I think that’s exactly what we want.

this is what I’ve tried,

in admin.py

class CustomerAdmin(admin.ModelAdmin):
    def change_view(self, request, object_id, extra_context=None):
        agent = Agent.object.get(user=request.user)
        permitted_fields = agent.permitted_fields # assume i have this setup...
        self.readonly_fields = get_not_permitted_fields(premitted_fields) # assume I have this function written somewhere
        return super(CustomerAdmin, self).change_view(request, object_id,
            extra_context=None) 

this works exactly that way I want: for the not permitted fields, set them to readonly…

thanks again,

  • 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-20T03:51:52+00:00Added an answer on May 20, 2026 at 3:51 am

    That is possible… You must use django admin methods as they described in here… You must define add_view, change_view and changelist_view functions…

    You must also find a way to group users (groups might be a good way, or you can use permissions). I create a model that extends User model, but you can find your own way…

    Second write basic add, change and listview founctions like:

    class CustomerAdmin(admin.ModelAdmin):
        list_display= ["fields that will be used for all users"]
    
        def changelist_view(self, request, extra_context=None):
            if request.user == "type a":
                self.list_display.extend["list of other fields"]
            return super(CustomerAdmin, self).changelist_view(request, extra_context)
    

    You must specify add, change (and changelist if required) views and handle each user type. Then Django will show related fields for the user. You extend list_display, fileds, exclude, list_filter and such django admin field display methods…

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

Sidebar

Related Questions

I'm starting to develop a facebook application using Django. I'm trying to choose the
I'm using Django and Python 2.6, and I want to grow my application using
I develop web applications using Django on Mac OSX 10.6. I use Django's built
I'm trying to develop an app using Django 1.1 on Webfaction. I'd like to
I'm using Django-Tagging, and I don't exactly need a cloud, I just want a
We are starting a new project to develop a website using django. We have
Using Django 1.1: The Django admin docs describe using arbitrary methods or attributes on
When using django, I believe you can swap out the built-in orm for sqlalchemy
I want to develop my application using google app engine into which I will
When using django, compressor, and clevercss, I set my css url to an absolute

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.