user2323711
user2323711

Reputation: 863

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

Upvotes: 14

Views: 7845

Answers (3)

zhaozhi
zhaozhi

Reputation: 1581

python manage.py migrate --fake

Upvotes: -5

joshua
joshua

Reputation: 2519

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.

Upvotes: 15

Darwin
Darwin

Reputation: 1859

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

 python manage.py syncdb

Upvotes: 3

Related Questions