3

I am able to run a Django Admin site and when I login as the SuperUser I'm able to modify my model as well. This part works perfectly. When I login as a user that is NOT a super user, the user does not see an option to modify this Model. When I logged in as a Super User and tried to give this user/group the permission to modify this model from the permission list, I couldn't find this permission in the list.

I see the following permissions:

  • admin|log entry|
  • .
  • .
  • auth|group|...
  • auth|message|...
  • auth|permission|...
  • content types|...
  • sessions|...

but nothing related to my ModelAdmin. My admin.py looks as follows:

from django.contrib import admin
from pl.models import *

class MyModelAdmin(admin.ModelAdmin):
    pass

admin.site.register(MyModel, MyModelAdmin)

Can only a super-user edit models specified via ModelAdmin? What if I want to permission a group to be able to do so for select models. Any way to do this? Thanks.

Sid
  • 7,511
  • 2
  • 28
  • 41

2 Answers2

3

You should be able to do that. Try running python manage.py syncdb again.

dan-klasson
  • 13,734
  • 14
  • 63
  • 101
  • I've already tried that and did so again and checked the database as well. Those permissions are just not being created. (Did a select * from auth_permission) – Sid Feb 08 '12 at 21:38
2

If you've already run syncdb and the permissions are still not there, then you must not have your app listed in INSTALLED_APPS. Otherwise, Django would automatically create them.

Additionally, you mention "nothing related to my ModelAdmin". The permissions are created for models, not ModelAdmins. You may have just mistyped that, but if you're looking for something related to the ModelAdmin itself, that might be your problem.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • +1 as your post pointed me in the right direction. I think the problem is with my directory structure. My INSTALLED_APPS has 'abc' as the app name while my models.py is in abc/xyz while my urls.py and settings.py are in abc/. If I change the app name in INSTALLED_APPS to abc/xyz the permissions are generated but then the rest of my stuff breaks (normal requests) – Sid Feb 08 '12 at 22:25
  • "abc" is likely your project, then, and "xyz" is your app. Depending on how your `PYTHONPATH` is setup, you may or may not need to prepend the project to the app in `INSTALLED_APPS`. Regardless, you use a `.` rather than a `/` in this scenario. So, it should either be `'abc.xyz',` or just `'xyz',` – Chris Pratt Feb 08 '12 at 22:30
  • I did use abc.xyz and the permissions were generated. However other urls broke. I'm gonna play with it a bit more but I think I know what the problem is. manage.py wasn't finding the correct app via INSTALLED_APPS – Sid Feb 08 '12 at 22:32