Django安装与使用

下载 Django-1.11.7.tar.gz   

2 解压

3 启动CMD 进入解压文件夹

4 执行 python setup.py install

5 创建项目

6创建app项目

7 settings.py中 installed_apps添加app名称,文档末尾添加static_url=‘/static/’   staticfiles_dirs=[os.path.join(base_dir“static”),‘django/static/’]

8 urls.py 文件中添加from blog.View import Vie  uripatterns=[url(r'^index/',Vie.index)]

9 from django.shorcuts import render

  from django.http import HttpResponse

  def index(request):

  return render(request,'index.html')

10 {% load static %}

 <img src="{% static 'images/a.jpg'%}">

<img src="../static/images/a.jpg">

原文地址:https://www.cnblogs.com/Justsoso-WYH/p/7825687.html