美文网首页Metis
Django 3.1安装运行

Django 3.1安装运行

作者: 万州客 | 来源:发表于2020-11-12 14:38 被阅读0次

时间又过了好几年,django都出到3.1了,在mac上,没有管理员帐号,先安装运行一番~

一,pip安装

安装django,指定版本
pip3 install django==3.1 --user

...
Successfully installed asgiref-3.2.10 django-3.1

二,建一个demo-project

保证django-admin.py在PATH路径中,且可执行。否则,可用绝对路径来定位
django-admin.py startproject demo-project
新建完成之后,进入demo-project目录,之后操作在这目录下。

三,迁移数据库变更

将默认的数据变更记录,迁移进数据库
python3 manage.py migrate

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 admin.0003_logentry_add_action_flag_choices... 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 auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK

四,创建一个超级管理员

python3 manage.py createsuperuser

Username (leave blank to use 'sky'): admin
Email address: admin@demo.com
Password: 
Password (again): 
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

五,启动django的demo-project项目

python3 manage.py runserver

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
November 12, 2020 - 06:25:46
Django version 3.1, using settings demo-project.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[12/Nov/2020 06:25:52] "GET / HTTP/1.1" 200 16351

访问http://127.0.0.1:8000


截屏2020-11-12下午2.37.43.png

相关文章

网友评论

    本文标题:Django 3.1安装运行

    本文链接:https://www.haomeiwen.com/subject/hmhpbktx.html