Reputation: 129
i have the following code in my models.py
from django.db import models
# Create your models here.
class LabName(models.Model):
labsname=models.CharField(max_length=30,unique=True)
#room_number=models.CharField(max_length=3)
def __unicode__(self):
return self.labsname
STAT=(('W','Working'),('N','Not Working'))
class ComponentDescription(models.Model):
lab_Title=models.ForeignKey('Labname')
component_Name = models.CharField(max_length=30)
description = models.TextField(max_length=200)
qty = models.IntegerField()
purchased_Date = models.DateField()
status = models.CharField(max_length=1,choices=STAT)
to_Do = models.CharField(max_length=30,blank=True)
remarks = models.CharField(max_length=30)
def __unicode__(self):
return self.component_Name
i have the following in my admin.py
from django.contrib import admin
from Lab_inventory.models import ComponentDescription,LabName
class ComponentDescriptionInline(admin.TabularInline):
model = ComponentDescription
extra=0
class LabNameAdmin(admin.ModelAdmin):
inlines = [
ComponentDescriptionInline,
]
class ComponentDescriptionAdmin(admin.ModelAdmin):
list_display=('lab_Title','component_Name','description','qty','purchased_Date','status','to_Do','remarks')
list_filter=('lab_Title','status','purchased_Date')
admin.site.register(LabName, LabNameAdmin)
admin.site.register(ComponentDescription,ComponentDescriptionAdmin)
i want to assign users with custom privilages .i mean that different users can modify only the labs that they are assigned with.Django admin allows to add edit lab permissions i.e edit,delete and modify labs.but The problem is that every user can access all the labs
Upvotes: 1
Views: 1353
Reputation: 515
If I understand the question correctly, you are trying to control permissions per object.
This should help: Adding per-object permissions to django admin
I've also heard that you can do this with the django-guardian package, although I have never tried it: http://pythonhosted.org/django-guardian/
Upvotes: 1