Django how to set main page

前端 未结 4 1990
予麋鹿
予麋鹿 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:02

    In case someone searching for an updated version of the answer..

    from django.urls import re_path
    from . import views
    
    urlpatterns = [
        re_path(r'^$', views.index, name='index')
    ]
    

    and in your views.py

    def index(req):
        return render(req, 'myApp/index.html')
    

提交回复
热议问题