Django how to set main page

前端 未结 4 1993
予麋鹿
予麋鹿 2021-01-07 18:38

i want to set a main page or an index page for my app. i tried adding MAIN_PAGE in settings.py and then creating a main_page view returning a main_page object, but it doesn\

4条回答
  •  终归单人心
    2021-01-07 19:01

    If you want to refer to a static page (not have it go through any dynamic processing), you can use the direct_to_template view function from django.views.generic.simple. In your URL conf:

    from django.views.generic.simple import direct_to_template
    urlpatterns += patterns("",
        (r"^$", direct_to_template, {"template": "index.html"})
    )
    

    (Assuming index.html is at the root of one of your template directories.)

提交回复
热议问题