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)

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