I`m trying to add my models ( the models are named "Question" and "Answer" respectively allocated in models.py archive) to the Django admin control center. So, to do that I make the following the settings in the following archives:
我试图将我的模型(模型分别命名为models.py archive中的“Question”和“Answer”)添加到Django管理控制中心。因此,为此,我在以下存档中进行以下设置:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admindocs',
'questionsandanswers',
)
After that I synchronize the database again to commit the change.
之后,我再次同步数据库以提交更改。
python manage.py syncdb
In the urls.py file I have the following setting:
在urls.py文件中,我有以下设置:
from django.conf.urls import patterns, include, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'miprimerproyecto.views.home', name='home'),
url(r'^blog/', include('blog.urls')),
................
url(r'^admin/', include(admin.site.urls)),
)
The admin.py file allocated inside of the models folders, has the following configuration:
在models文件夹中分配的admin.py文件具有以下配置:
from django.contrib import admin
from questionsandanswers.models import Question, Answer
admin.site.register(Question)
admin.site.register(Answer)
After the I restart the server again:
我再次重启服务器后:
python manage.py runserver
But the when I enter in the admin console I don' t see the models on the board.
但是当我进入管理控制台时,我看不到主板上的模型。
I would be very grateful If somebody could help me to solve this issue.
如果有人能帮助我解决这个问题,我将非常感激。
2 个解决方案
#1
1
You probably don't have permissions set for those models yet. You can check that by logging in with a superuser account, which has all permissions. If your superuser account shows the admin options for the new models but your regular account doesn't, that confirms that your regular account lacks permissions for those models. You can use the superuser account to add permissions to a group or directly to the account you'd like to use in the auth
admin.
您可能还没有为这些模型设置权限。您可以使用具有所有权限的超级用户帐户登录来检查。如果您的超级用户帐户显示新模型的管理员选项,但您的常规帐户没有,则会确认您的常规帐户缺少这些模型的权限。您可以使用超级用户帐户向组添加权限,也可以直接添加到您要在auth admin中使用的帐户。
#2
0
Instead of running python manage.py syncdb
try python manage.py makemigrations
and then run python manage.py migrate
then start your server and check again
而不是运行python manage.py syncdb尝试python manage.py makemigrations然后运行python manage.py migrate然后启动你的服务器并再次检查
#1
1
You probably don't have permissions set for those models yet. You can check that by logging in with a superuser account, which has all permissions. If your superuser account shows the admin options for the new models but your regular account doesn't, that confirms that your regular account lacks permissions for those models. You can use the superuser account to add permissions to a group or directly to the account you'd like to use in the auth
admin.
您可能还没有为这些模型设置权限。您可以使用具有所有权限的超级用户帐户登录来检查。如果您的超级用户帐户显示新模型的管理员选项,但您的常规帐户没有,则会确认您的常规帐户缺少这些模型的权限。您可以使用超级用户帐户向组添加权限,也可以直接添加到您要在auth admin中使用的帐户。
#2
0
Instead of running python manage.py syncdb
try python manage.py makemigrations
and then run python manage.py migrate
then start your server and check again
而不是运行python manage.py syncdb尝试python manage.py makemigrations然后运行python manage.py migrate然后启动你的服务器并再次检查