Django note3

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)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章