Django通过pycharm创建后,如何登录admin后台?
Posted yy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Django通过pycharm创建后,如何登录admin后台?相关的知识,希望对你有一定的参考价值。
问题背景:
使用pycharm创建完成django项目(项目名称为:mydjangopro,app名称为my_blog)
,
本想登录后台直接输入地址:http://127.0.0.1:8000/admin后,登录页面出现了,随便(username:admin,password:admin)输入了账户名和密码却进入了错误黄页:
从错误代码中我们也发现说是数据没有找到表相关问题,从程序工程上此时查看多了一个sqllite的数据库,这说明默认django使用的数据库是sqllite。
解决上边问题的方案:
1)在pycharm的tools->"Run manage.py task...\':
直接点击,会在pycharm右侧代码栏下边弹出一个“manage.py@mydjangopro”命令运行窗口。
2)在“manage.py@mydjangopro”命令运行窗口中输入:makemigrations
manage.py@mydjangoapro > makemigrations "E:\\Program Files\\JetBrains\\PyCharm 2017.2.3\\bin\\runnerw.exe" C:\\Python27\\python.exe "E:\\Program Files\\JetBrains\\PyCharm 2017.2.3\\helpers\\pycharm\\django_manage.py" makemigrations E:/Work/django/mydjangoapro No changes detected
3)在“manage.py@mydjangopro”命令运行窗口中输入:migrate
manage.py@mydjangoapro > migrate "E:\\Program Files\\JetBrains\\PyCharm 2017.2.3\\bin\\runnerw.exe" C:\\Python27\\python.exe "E:\\Program Files\\JetBrains\\PyCharm 2017.2.3\\helpers\\pycharm\\django_manage.py" migrate E:/Work/django/mydjangoapro Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying sessions.0001_initial... OK Following files were affected E:\\Work\\django\\mydjangoapro\\db.sqlite3 Process finished with exit code 0
4)在“manage.py@mydjangopro”命令运行窗口中输入:createsuperuser
manage.py@mydjangoapro > createsuperuser "E:\\Program Files\\JetBrains\\PyCharm 2017.2.3\\bin\\runnerw.exe" C:\\Python27\\python.exe "E:\\Program Files\\JetBrains\\PyCharm 2017.2.3\\helpers\\pycharm\\django_manage.py" createsuperuser E:/Work/django/mydjangoapro Username (leave blank to use \'administrator\'): admin Email address: admin@admin.com Warning: Password input may be echoed. Password: admin Warning: Password input may be echoed. Password (again): admin The password is too similar to the email address. This password is too short. It must contain at least 8 characters. This password is too common. Warning: Password input may be echoed. Password: new.1234 Warning: Password input may be echoed. Password (again): new.1234 Superuser created successfully. Following files were affected E:\\Work\\django\\mydjangoapro\\db.sqlite3 Process finished with exit code 0
5)重新进入登录页面:http://127.0.0.1:8000/admin,在username中输入admin,密码输入:new.1234,点击登录之后成功跳转到了后台管理页面:
以上是关于Django通过pycharm创建后,如何登录admin后台?的主要内容,如果未能解决你的问题,请参考以下文章
Django通过django_auth_ladp接入AD认证登录
PyCharm 创建指定版本的 Django (超详细图解)