Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django model permissions not picked up on admin

I've added permission to my model and I would like to create a group in admin that uses this permission.

The problem is that the new permission is not listed in the permissions list.

is there something I need to do to add it to that list?

    class Meta:
        permissions = (
            ("add_remove_job", "Can add/remove jobs"),
        )

SOLUTION: It is a known limitation of South, the solution is to do syncdb --all

like image 985
user2323711 Avatar asked Apr 26 '13 12:04

user2323711


Video Answer


2 Answers

try:

manage.py syncdb --all

Otherwise, You can force django to generate permissions for a particular app:

from django.contrib.auth.management import create_permissions
from django.apps import apps

create_permissions(apps.get_app_config('my_app_name'))

This will do all models in the app. You can substitute a list of model class objects instead of 'get_models()' if you only want a subset.

like image 64
joshua Avatar answered Oct 23 '22 20:10

joshua


What you need to do is a syncdb each time you add/modify a permission for a model.

 python manage.py syncdb
like image 3
Darwin Avatar answered Oct 23 '22 20:10

Darwin