django的项目创建简明流程

时间:2023-03-10 02:38:31
django的项目创建简明流程

个人理解,不妥之处请指出

创建项目:django-admin startproject user_sys
创建APP:python manage.py startapp auth
测试项目创建是否成功:localhost:8000 It Works!
#注册APP到settings中
设置templates路径:'DIRS': [os.path.join(BASE_DIR,'templates')],
创建数据模型models
进行数据迁移python manage.py migrate 数据模型有变动则需要进行 python manage.py makemigrations操作
创建超级用户 python manage.py createsuperuser (如果提示要设置max_length,则需要设置models中的字段长度限制)
新增一个视图:send_register
增加一条路由url(前提要导入APP的视图views)
在APP文件夹下新建一个templates文件夹,并且新增一个register.html文件
运行 python manage.py runserver
打开 localhost:8000/url 即可