结果
Result.png Structure.png
总结
1. templates中加入index.html
2. app中的view.py中,加入index的网页请求方法:
def index(request):
return render(request,'index.html')
render_defination.png
3. site中的urls.py中,加入index的网页的url链接:
from django.conf.urls import url
from django.contrib import admin
from personsite.views import index
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^index/', index)
]
4. 加入静态static目录,加入css和image资源:
static_path.png5. site中的settings中,加入static的路径:
STATIC_URL = '/static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR,'static'),)
6. 模板语言编辑index的路径:
(1)引入static头文件
{% load static %}
(2)修改资源路径
{% static 'src_path' %}
<link rel="stylesheet" href="{% static 'css/layouts/blog.css' %}">
<img class="post-avatar" alt="Reid Burke's avatar" height="48" width="48" src="{% static 'img/common/reid-avatar.png' %}">
网友评论