Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding new custom permissions in Django

I am using custom permissions in my Django models like this:

class T21Turma(models.Model):     class Meta:         permissions = (("can_view_boletim", "Can view boletim"),                        ("can_view_mensalidades", "Can view mensalidades"),) 

The problem is that when I add a permission to the list it doesn't get added to the auth_permission table when I run syncdb. What am I doing wrong. If it makes any difference I am using south for database migrations.

like image 275
gerdemb Avatar asked Nov 16 '09 12:11

gerdemb


People also ask

How do I set custom permissions in Django?

Django Admin Panel : In Admin Panel you will see Group in bold letter, Click on that and make 3-different group named level0, level1, level3 . Also, define the custom permissions according to the need. By Programmatically creating a group with permissions: Open python shell using python manage.py shell.

How do I add user permissions in Django?

With Django, you can create groups to class users and assign permissions to each group so when creating users, you can just assign the user to a group and, in turn, the user has all the permissions from that group. To create a group, you need the Group model from django. contrib. auth.


1 Answers

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.

like image 162
Daniel Naab Avatar answered Oct 21 '22 09:10

Daniel Naab