In this video, we power up our Django app by creating a dynamic landing page from scratch. In this episode, you’ll learn how to:
Securely Manage API Keys:
Get your free TMDB API key and keep it safe using a .env file with python-dotenv.
Configure Environment Variables:
Update your Django settings to load your API key securely.
Build Dynamic Views & Templates:
Write a Django view that fetches movie data from the TMDB API based on user-specified criteria (category or search term) and pass that data to your template.
Design a Responsive Landing Page:
Create a user-friendly page using Django’s templating language and Bootstrap. You’ll add a category dropdown, search form, and display movies in sleek Bootstrap cards.
Implement Robust Error Handling:
Use try/except blocks to manage API errors gracefully and inform users if something goes wrong.
This hands-on, beginner-friendly video teaches you real-world techniques to integrate external APIs and build dynamic, production-ready web pages with Django, HTMX, and Bootstrap.
Chapters:
00:00 – What We’ll Do and Learn (Objectives)
01:24 – Quick Recap: What We Covered in the Last Video
02:20 – Introducing the Live Data Source (The Movie Database TMDB API)
02:57 – Using Python-dotenv & .env: Keeping Our API Key Safe and Accessible
05:30 – Creating a Dropdown Menu with Categories and Styling it with Bootstrap
09:22 – Building the Categories Form
12:07 – Setting Up the TMDB API Categories/Movie Lists Base URL
13:00 – Overview of Python’s Requests Library
13:36 – Making GET Requests to the TMDB API to Fetch Movie Data and Passing it to the Template
16:36 – Looping Through Movies and Placing Them in Bootstrap Cards
18:23 – Displaying Movie Posters (Using Django Template Variables)
19:25 – Ensuring the Category Dropdown Shows the Selected Category (Using Django Template If Statements/Conditions)
23:24 – Using the Django Template Filter: floatformat
24:07 – Finalizing the Landing Page Layout and Card Styling
26:45 – Adding Movie Search Functionality
33:40 – Implementing Request Error Handling (Try/Except Block)
35:28 – Adding an Error Message to the Template
🔗Important Resources and Links:
Django Docs:
https://docs.djangoproject.com/en/5.0/
Github Repo:
https://github.com/PikoCanFly/Learn-Django-HTMX-Course/tree/part-2
🧡 If you have found this content useful consider becoming my Patreon: 💜
https://www.patreon.com/PikoCanFly
https://www.patreon.com/PikoCanFly
コメント
Another great one! Thanks yiu! Will the next video show how to use htmx?