1、需要安装如下:
2.添加工程代码init
然后添加代码如下:
import pymysql
pymysql.install_as_MySQLdb()
db = pymysql.connect("localhost", 'root', 'root', 'pythontest') #数据库的用户名密码及数据库名
cursor = db.cursor()
cursor.execute(
'SELECT VERSION()')
data = cursor.fetchone()
print("Versionis %s" % data)
db.close()
然后
anage.py@studyJD > makemigrations
manage.py@studyJD > migrate
(venv) C:\Users\Administrator\PycharmProjects\untitled1>python manage.py showmigrations
Version is 5.7.26
admin
[ ] 0001_initial
[ ] 0002_logentry_remove_auto_add
[ ] 0003_logentry_add_action_flag_choices
auth
[ ] 0001_initial
[ ] 0002_alter_permission_name_max_length
[ ] 0003_alter_user_email_max_length
[ ] 0004_alter_user_username_opts
[ ] 0005_alter_user_last_login_null
[ ] 0006_require_contenttypes_0002
[ ] 0007_alter_validators_add_error_messages
[ ] 0008_alter_user_username_max_length
[ ] 0009_alter_user_last_name_max_length
[ ] 0010_alter_group_name_max_length
[ ] 0011_update_proxy_permissions
contenttypes
[ ] 0001_initial
[ ] 0002_remove_content_type_name
myAPP
(no migrations)
sessions
[ ] 0001_initial
好了,可以的登录django的后台了,这里面已经帮你创建了基本的框架了,先run一下这个工程
然后访问:http://127.0.0.1:8000/admin