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
解决方案:这是South的已知限制,解决方案是执行syncdb --all
3 个解决方案
#1
12
try:
尝试:
manage.py syncdb --all
Otherwise, You can force django to generate permissions for a particular app:
否则,您可以强制django为特定应用生成权限:
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.
这将在应用程序中执行所有模型。如果只需要子集,则可以替换模型类对象列表而不是'get_models()'。
#2
2
What you need to do is a syncdb each time you add/modify a permission for a model.
每次添加/修改模型的权限时,您需要做的是syncdb。
python manage.py syncdb
#3
-3
python manage.py migrate --fake
#1
12
try:
尝试:
manage.py syncdb --all
Otherwise, You can force django to generate permissions for a particular app:
否则,您可以强制django为特定应用生成权限:
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.
这将在应用程序中执行所有模型。如果只需要子集,则可以替换模型类对象列表而不是'get_models()'。
#2
2
What you need to do is a syncdb each time you add/modify a permission for a model.
每次添加/修改模型的权限时,您需要做的是syncdb。
python manage.py syncdb
#3
-3
python manage.py migrate --fake