1. 程式人生 > >Django Flatpage設置

Django Flatpage設置

域名 att down block 鏈接 views code 參考 port

參考鏈接:https://docs.djangoproject.com/en/1.11/ref/contrib/flatpages/

知識點:

  • 通過django.site數據庫記錄表,對應域名和請求站點的關系;

    SITE_ID 進行設置

  • URLconf中進行通配設置,但須放置到配置最後面:


 urlpatterns += [
        url(r‘(?P<url>.*/)$‘), views, name="xxx"),
]
  • URLconf中進行硬編碼:

from django.contrib.flatpages import views

urlpatterns += [
    url(r‘^about-us/$‘, views.flatpage, {‘url‘: ‘/about-us/‘}, name=‘about‘),
    url(r‘^license/$‘, views.flatpage, {‘url‘: ‘/license/‘}, name=‘license‘),
]

Django Flatpage設置