显示登陆首页实现步骤
1.创建Django项目
2.在终端中创建应用python manage.py startapp 应用名
3.在项目包中的settings.py文件中添加应用
‘’‘
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'stu'
]
’‘’
4.确定访问路径:http://127.0.0.1:8000/student/
5.配置项目根路由:
‘’‘
from django.contrib import admin
from django.urls import path, include
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('student/', include('stu.urls'))
]
’‘’
6.在应用包下创建并配置urls.py文件
‘’‘
#coding=utf-8
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('', views.login_view)
]
’‘’
7.在应用包下view.py文件创建函数
8.在templates目录下创建login.html
来源:https://www.cnblogs.com/dangjingwei/p/12642739.html