Home and landing page configuration

1. Create a new static directory and put the static files of css, js, images, media, and img into the static directory

Static files:

Link: https://pan.baidu.com/s/1tpqF26h-WecV_bcyQNmsjQ 
extraction code: 25y8

Second, set the static directory location in the project settings.py file

STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR,"static"),
)

Third, put index.html and login.html into the templates directory

Fourth, modify the index.html and login.html static file reference paths such as css, js, pictures, etc.

1、将..ctrl+R 修改为/static 如修改index

<head>
	<meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" >
	<title></title>
	<link rel="stylesheet" type="text/css" href="/static/css/reset.css">
	<link rel="stylesheet" type="text/css" href="/static/css/animate.css">
	<link rel="stylesheet" type="text/css" href="/static/css/style.css">
    
    <script src="/static/js/jquery.min.js" type="text/javascript"></script>
    <script src="/static/js/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>

</head>

2、将index.html 登录成功代码注释,修改点击登录访问路径代码如下:
<!--登录后跳转-->
<a style="color:white" class="fr registerbtn" href="register.html">注册</a>
<!--登录访问路径href-->
<a style="color:white" class="fr loginbtn" href="/login/">登录</a>

<!-- <div class="personal">
	<dl class="user fr">
		<dd>bobby<img class="down fr" src="/static/images/top_down.png"/></dd>
		<dt><img width="20" height="20" src="/static/media/image/2016/12/default_big_14.png"/></dt>
	</dl>
	<div class="userdetail">
		<dl>
			<dt><img width="80" height="80" src="/static/media/image/2016/12/default_big_14.png"/></dt>
			<dd>
				<h2>django</h2>
				<p>bobby</p>
			</dd>
		</dl>
		<div class="btn">
			<a class="personcenter fl" href="usercenter-info.html">进入个人中心</a>
			<a class="fr" href="/logout/">退出</a>
		</div>
	</div>
</div>
-->

</div>
</div>
                            
                                

Fifth, add the access path of index and login, modify the urls.py code as follows

"""testdjango URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
# xadmin的依赖
import xadmin
xadmin.autodiscover()

# version模块自动注册需要版本控制的 Model
from xadmin.plugins import xversion
from django.conf.urls import url
from django.views.generic import TemplateView
xversion.register_models()


urlpatterns = [
    url(r'^adminx/', xadmin.site.urls),
    # index访问路径
    url(r'^$', TemplateView.as_view(template_name="index.html"), name="index"),
    # login访问路径
    url(r'^login/$', TemplateView.as_view(template_name="login.html"), name="login"),
]

6. Whether the start-up project access verification is successful

Published 42 original articles · praised 11 · 20,000+ views

Guess you like

Origin blog.csdn.net/QWERTY55555/article/details/105513404