标签:计算 similar sts turn klist hold abs roc -o
调用本地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>
按照用户输入的用户名和账号做出跳转链接
标签:计算 similar sts turn klist hold abs roc -o
原文地址:https://www.cnblogs.com/zqh962903415/p/13926940.html