Django note3

来源:互联网 发布:通达信选股源码 编辑:程序博客网 时间:2024/05/17 04:22

1、templates(模板)/static(静态文件)

1.1、使用时建立在项目文件夹下,与app同级

1.2、修改项目文件setting.py中的路径

1.3、templates包括html文件、static包括css、js、image、svg(矢量图片、xml文本描述)等资源

2、django template language

{%text%}

{{variable}}

3、resolve/reverse

4、{% static %}

4.1、The {% static %} template tag uses the STATIC_URL configuration in the settings.py to compose the final URL

4.2、The template tag {% static %} is used to compose the URL where the resource lives. In this case, the {% static ‘css/bootstrap.min.css’ %} will return /static/css/bootstrap.min.css, which is equivalent to http://127.0.0.1:8000/static/css/bootstrap.min.css.

5、admin(Django自带后台)

python manage.py createsuperuser
注册Board models
from .models import Board(.表示在当前目录下的model文件)
admin.site.register(Board)(注册model)