简体   繁体   English

在Django管理员中无法以超级用户身份登录(Django Girls Tutorial)

[英]Unable to login as superuser in Django admin (Django Girls Tutorial)

I have created a app in python 3.5 and django 1.8.5 on WIndows 7(32bit). 我在Windows 7(32位)上的python 3.5django 1.8.5创建了一个应用程序。 I have create new user in my app but have some problem with login. 我在我的应用中创建了新用户,但登录时遇到了一些问题。

When I logged in with newly created superuser then this error message is shown: 当我使用新创建的超级用户登录时,将显示此错误消息:

>>Error:- Please enter the correct username and password for a staff account. Note that both fields may be case-sensitive.

I followed the Django Girls Tutorial and everything worked fine till I reached the Django Admin part. 我遵循了Django Girls教程,并且一切正常,直到到达Django Admin部分为止。

The tutorial asks the reader to start the server then create the superuser. 本教程要求读者启动服务器, 然后创建超级用户。 I did it the other way round: created the super-user (admin) then started the server (does this make a difference?). 我反过来做了:创建超级用户(admin), 然后启动服务器(这有所作为吗?)。 Navigated to http://localhost:8000/admin and tried to log in. 导航到http:// localhost:8000 / admin并尝试登录。

The login didn't work. 登录无效。 Then, while the server was running, I first created one super-user (gaurav) and then another (sharma) and neither one worked. 然后,在服务器运行时,我首先创建了一个超级用户(gaurav),然后创建了另一个超级用户(sharma),但都没有一个正常工作。 All three super-users had the same password. 三个超级用户都具有相同的密码。

Please someone help me to solve this issue. 请有人帮我解决这个问题。 :) :)

Maybe you've done this, in which case ignore my answer. 也许您已经做到了,在这种情况下,请忽略我的回答。 But you didn't mention migrations. 但是您没有提到迁移。 Your problem would be solved by manage.py migrations then manage.py migrate -- as the superuser needs to be stuck into the database first. 您的问题将通过manage.py迁移然后再进行manage.py迁移来解决-因为超级用户需要首先插入数据库。 It doesn't matter whether the server is running first or second. 服务器运行的是第一还是第二都没有关系。 (You will however run into problems if adding the superuser WHILE the server is running on a localhost environment.) (但是,如果在服务器在本地主机环境上运行时添加超级用户,则会遇到问题。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM