4-1homework

结果


4-1homework_第1张图片
Result.png
4-1homework_第2张图片
Structure.png

总结


1. templates中加入index.html

2. app中的view.py中,加入index的网页请求方法:

def index(request):
    return render(request,'index.html')
4-1homework_第3张图片
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资源:

4-1homework_第4张图片
static_path.png

5. site中的settings中,加入static的路径:

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

6. 模板语言编辑index的路径:

(1)引入static头文件

{% load static %}

(2)修改资源路径

{% static 'src_path' %}



Reid Burke's avatar

你可能感兴趣的:(4-1homework)