1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Django通过pycharm创建后 如何登录admin后台?

Django通过pycharm创建后 如何登录admin后台?

时间:2023-10-11 00:08:00

相关推荐

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 .2.3\bin\runnerw.exe" C:\Python27\python.exe "E:\Program Files\JetBrains\PyCharm .2.3\helpers\pycharm\django_manage.py" makemigrations E:/Work/django/mydjangoaproNo changes detected

3)在“manage.py@mydjangopro”命令运行窗口中输入:migrate

manage.py@mydjangoapro > migrate"E:\Program Files\JetBrains\PyCharm .2.3\bin\runnerw.exe" C:\Python27\python.exe "E:\Program Files\JetBrains\PyCharm .2.3\helpers\pycharm\django_manage.py" migrate E:/Work/django/mydjangoaproOperations to perform:Apply all migrations: admin, auth, contenttypes, sessionsRunning migrations:Applying contenttypes.0001_initial... OKApplying auth.0001_initial... OKApplying admin.0001_initial... OKApplying admin.0002_logentry_remove_auto_add... OKApplying contenttypes.0002_remove_content_type_name... OKApplying auth.0002_alter_permission_name_max_length... OKApplying auth.0003_alter_user_email_max_length... OKApplying auth.0004_alter_user_username_opts... OKApplying auth.0005_alter_user_last_login_null... OKApplying auth.0006_require_contenttypes_0002... OKApplying auth.0007_alter_validators_add_error_messages... OKApplying auth.0008_alter_user_username_max_length... OKApplying sessions.0001_initial... OKFollowing files were affected E:\Work\django\mydjangoapro\db.sqlite3Process finished with exit code 0

4)在“manage.py@mydjangopro”命令运行窗口中输入:createsuperuser

manage.py@mydjangoapro > createsuperuser"E:\Program Files\JetBrains\PyCharm .2.3\bin\runnerw.exe" C:\Python27\python.exe "E:\Program Files\JetBrains\PyCharm .2.3\helpers\pycharm\django_manage.py" createsuperuser E:/Work/django/mydjangoaproUsername (leave blank to use 'administrator'): adminEmail address: admin@Warning: Password input may be echoed.Password: adminWarning: Password input may be echoed.Password (again): adminThe 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.1234Warning: Password input may be echoed.Password (again): new.1234Superuser created successfully.Following files were affected E:\Work\django\mydjangoapro\db.sqlite3Process finished with exit code 0

5)重新进入登录页面:http://127.0.0.1:8000/admin,在username中输入admin,密码输入:new.1234,点击登录之后成功跳转到了后台管理页面:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。