13

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

user2323711
  • 843
  • 1
  • 7
  • 13

3 Answers3

15

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.

nont
  • 9,322
  • 7
  • 62
  • 82
joshua
  • 2,509
  • 17
  • 19
  • 1
    Unfortunatelly doesn't work with Django 1.7 anymore. You have to `from django.apps import apps` and then call `create_permissions(apps.get_app_config('my_app_name'))` but (I think if you use migrations) it will return after `if not router.allow_migrate(using, Permission)` without doing anything. – yofee Oct 31 '14 at 05:57
  • Important the `--all` flag for apps using South! Thanks. – Caumons Mar 08 '16 at 17:32
3

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

 python manage.py syncdb
Darwin
  • 1,809
  • 15
  • 17
-5
python manage.py migrate --fake
Tunaki
  • 132,869
  • 46
  • 340
  • 423
zhaozhi
  • 1,491
  • 1
  • 16
  • 19