django include template code example

Example 1: django include

# import include
from django.urls import include, path

urlpatterns = [
    path('index/', views.index, name='main-view'),
    path('bio//', views.bio, name='bio'),
    path('articles//', views.article, name='article-detail'),
    path('articles///', views.section, name='article-section'),
    path('weblog/', include('blog.urls')),
    ...
]

Example 2: how to connect templates in django

# Template directory setting
TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), 'templates'),
)

Example 3: django url template

Django URL Mapping

Example 4: django html templates

Django templates folder

Tags:

Misc Example