[Django]-Working with Django Model Permission raises DoesNotExist error

5👍

try doing:

python manage.py syncdb --all 

or make your own migration to handle the new permission (there is a bug with south that prevents autocreation of migrations for guardian permissions)

1👍

I believe syncdb didn’t the trick here. I suppose your code started to work when you added more permission to the list.

There’s a error with this line:

permissions = (('view_news', _('view news')))

It should be:

permissions = (('view_news', _('view news')),)

Note the missing comma. Permissions is a tuple of tuples that are pairs of kind (permission code, permission description)

edit:

I fell into the same trap once. The best way to avoid it is organize the code as follow even with one permission:

permissions = (
    ('view_news', _('view news')),
)

After that remember to do a syncdb you as mentioned by @Foo Party and @sogeking

$ python manage.py syncdb

Leave a comment