Загрузка...

Django Tutorial #5: Django Templates & Context | TemplateDoesNotExist | HTML&CSS Basics | BasicToTop

In this session, we explore Django Templates, understand common template errors, and learn how to connect Python code with dynamic HTML using Django’s powerful template engine.
We also fix the common TemplateDoesNotExist error and understand how Template (T) → View (V) → Model (M) flow works in Django’s MVT architecture.

This session focuses on rendering HTML pages, applying CSS, and passing data from views to templates using context.

Creating templates folder in project
✔️ Adding templates path inside TEMPLATES['DIRS']
✔️ Creating home.html, about.html, test.html
✔️ Using render() instead of HttpResponse
✔️ Passing context (data) from views to HTML
✔️ Inline CSS, Internal CSS examples
✔️ URL → View → Template workflow explained
✔️ Linking pages using a tag

📁 Files Explained:

🟦 settings.py
• BASE_DIR
• TEMPLATE_DIR
• Updating TEMPLATES (DIRS & APP_DIRS)

🟦 mainapp/views.py
• home() view with context
• about() view
• Rendering templates
• Sending dynamic data (trainer variable)

🟦 mainapp/urls.py
• path('', home)
• path('about/', about)

🟦 Project-level urls.py
• include('mainapp.urls')
• include('testapp.urls')

🟦 HTML Templates
• home.html
• about.html
• test.html
• Using internal CSS
• Using inline CSS
• Using HTML tags: h1, p, hr, br, a

🌐 Output:
Your Django app now loads real HTML templates, applies CSS, and displays dynamic data using context — no more plain HttpResponse.

🌟 About BasicToTop
BasicToTop is here to help you move forward — from basic to top.

🔔 Subscribe for more Django & Python tutorials
👍 Like the video if it helped
💬 Ask your doubts in comments — I reply to everyone

📌 Resources & Links:
‣ BasicToTop Website: https://basictotop.in

#Django #Python #WebDevelopment #DjangoTemplates #DjangoContext #BeginnerDjango #BasicToTop #basic to top #ram basictotop #DjangoCourse #PythonTraining

Видео Django Tutorial #5: Django Templates & Context | TemplateDoesNotExist | HTML&CSS Basics | BasicToTop канала BasicToTop
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять