Adding new custom permissions in Django Adding new custom permissions in Django django django

Adding new custom permissions in Django


South does not track django.contrib.auth permissions. See ticket #211 for more information.

One of the comments on the ticket suggests that using the --all option on syncdb may solve the problem.


If you want "manage.py migrate" to do everything (without calling syncdb --all). You need to create new permissions with a migration:

user@host> manage.py datamigration myapp add_perm_foo --freeze=contenttypes --freeze=auth

Edit the created file:

class Migration(DataMigration):    def forwards(self, orm):        "Write your forwards methods here."        ct, created = orm['contenttypes.ContentType'].objects.get_or_create(            model='mymodel', app_label='myapp') # model must be lowercase!        perm, created = orm['auth.permission'].objects.get_or_create(            content_type=ct, codename='mymodel_foo', defaults=dict(name=u'Verbose Name'))


This worked for me:

./manage.py update_permissions

It is a django-extensions thing.