调用本地css文件的方法

setting.py里面的内容

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '9ssccke32^tmaoq4rv_ccc&_2*emfq@vx#2g+-_xyo(c1@*tbo' # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
] MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
] ROOT_URLCONF = 'ServeProj.urls' TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
] WSGI_APPLICATION = 'ServeProj.wsgi.application' # Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
} # Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
] # Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/ STATIC_URL = '/static/'
#定义了 ip/static 是存放数据的文件夹
STATICFILES_DIRS=[
os.path.join(BASE_DIR,'static'), #相当于设置 ip/static这个数据文件夹 等同于 计算机内django工程文件夹的绝对路径/static
os.path.join(BASE_DIR,'static_img'), #相当于设置 ip/static这个数据文件夹 等同于 计算机内django工程文件夹的绝对路径/static_image
#以上就设置了如果浏览器找ip/static 那就去 django工程文件夹的绝对路径/static 或者 django工程文件夹的绝对路径/static_image里面找
]

url.py里的内容

from django.contrib import admin
from django.urls import path
from django.shortcuts import HttpResponse,render def index(request):
#业务
res=HttpResponse('进来的页面时index') #返回自己想要的字符串
return res def sb(request):
return render(request,'sb.html') #返回自己想展示的网页 def login(request):
return render(request,'login.html') urlpatterns = [
path('admin/', admin.site.urls), #这一条是自带的
path('index/',index), #这一条是自己写的,如果输入index的界面那么跳转到index函数
path('sb/',sb), #这一条是自己写的,如果输入sb的界面那么跳转到sb函数
path('login/',login) #这一条是自己写的,如果输入sb的界面那么跳转到sb函数
]

login.html里的内容

<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="txt/html; charset=utf-8"/>
<!-- 控制网页为utf8编码,必须放在最前面 -->
<link rel="stylesheet" href="/static/bootstrap.css">
<!-- 这是bootcss的核心样式,用bootcss都要这个-->
<link href="/static/signin.css" rel="stylesheet">
<!-- 这是signin的核心样式,用bootcss都要这个--> <style>
.city {
float: left;
margin: 5px;
padding: 15px;
width: 300px;
height: 300px;
border: 1px solid black;
}
</style>
</head> <body>
<img src="/static/上课时间.jpg" alt="">
<img src="/static/遗传算法.png" alt="">
<!-- 引入图片,图放在django工程文件夹下面的static或者static_img里面-->
<div class="container">
<form class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required="" autofocus="">
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required="">
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
</div> <!-- /container -->
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> </body> </html>

按照用户输入的用户名和账号做出跳转链接

最新文章

  1. 使用极光/友盟推送,APP进程杀死后为什么收不到推送(转)
  2. Eclipse导入现有项目
  3. MySQL数据类型——数值类型
  4. git的几种回滚 git revert 和 git reset的区别
  5. Microsoft Office Excel 不能访问文件 的解决办法
  6. Machine Learning for hackers读书笔记(三)分类:垃圾邮件过滤
  7. .NET开源工作流RoadFlow-流程设计-流转条件设置(路由)
  8. Logstash 默认不处理一天前的文件
  9. Android使得手机拍照功能的发展(源共享)
  10. 从netty源码里拿到的关于http错误码,自己学习下
  11. python进阶(4):初始面向对象
  12. C语言_了解一下C语言中的四种存储类别
  13. protel dxp 2004安装与破解
  14. wildfly 10上使用最新的 Hibernate ORM OGM
  15. Python3-进程
  16. day37-多进程多线程二-锁
  17. 求Sn=a+aa+aaa+aaaa+aaaaa的前5项之和,其中a是一个数字
  18. vue属性值调方法
  19. 怎么解决BarTender因为未检测到IIS安装失败的问题
  20. Java连接GBase并封装增删改查

热门文章

  1. mini-web框架-元类-总结(5.4.1)
  2. 带你探究Python的诞生和由来
  3. nodejs+express+mongodb 快速接口开发
  4. js--数组的reduce()方法的使用介绍
  5. java中token的生成和验证
  6. java使用map去重复
  7. JavaDailyReports10_18
  8. tcp聊天
  9. express安装问题
  10. [开源软件] 腾讯云Linux服务器一键安装LAMP/LNMP/LANMP环境 转