Django with HTMX Tutorial #2 - Project Setup

Net Ninja · Beginner ·🌐 Frontend Engineering ·1y ago

Key Takeaways

Sets up a Django project with HTMX using a GitHub repository and Python virtual environment

Full Transcript

so in this video we're going to set up the project and we're going to use this GitHub repository which contains some starter code in order to do that and there will be a link to this below the video the repository is called HTM X contact Hub and this contains a jangle project it's called Contact Hub and there's a single application called contacts within that project so this contains the starter code and each video will have a branch within this repository now to get started you need to clone this and you can use the get clone command I already have that project Loc here and I've opened it in vs code and within that Parent Directory we're going to set up a python virtual environment so what we're going to run here is the python DM command and we're going to use the venv module in Python and let's create a virtual environment called venv HTM X and once we set this up we're going to take a look at the starter code and what's provided in that now you'll notice when that command completes we have the virtual environment directory here on the left hand side and we can actually activate that environment if you're on Windows it's in the scripts directory and it's the activate script if you're on Mac OS or any kind of Unix system it's going to be in a bin directory and you can use the source command in order to activate that now on Windows we're going to go to the scripts directory and we're going to run this activate script that will activate the environment and then what we have within the starter code is this requirements. text file so if we take a quick look at that you can see the requirements for the starter code here we have jangle version 5.1.3 and we're also using Jango extensions here as well which is a convenient package for Jang applications and there are some other dependencies that jangle uses here as well so in order to install those what we're going to do is we're going to CD into the HTM X contact Hub directory and we can run pip install and then the- R command and the file name is requirements. text that's going to install all of those into the virtual environment and once that's completed we can clear the terminal and there's two more commands and it's Python manage.py and we're going to run the migrate command to create the SQL light database if we look on the left this creates that db. SQL light 3 file and that's going to be the database for this project and the final command I want to run here is manage.py and it's run server and that's actually going to start the Jango development server and we can then take a look at the application on Local Host 8,000 so I'm going to go to this URL here and you can see here the amazing website we've got here in the Stalter code it just has a header that says contact manager now let's take a quick look at what's in the starter code so in the contacts jangle application we have a templates directory that contains a base template and then contacts. HTML extends That Base template and that is what contains this H1 header and if you look at views.py we have a single jangle view in this application and all it's doing at the moment is rendering contacts. HTML and we have an empty context at the moment we're going to build that up as we progress through this series and we're going to create some jangle views for htx based functionality now one thing we've added to the starter code in models.py is this user model here here so we've extended the abstract user from jangle and that's a custom user model that we're using in the application and if we go to the Jango settings.py in the starter code if we scroll to the bottom here we have the O user model and we're setting it to the user model in the contct application so that's the Stalter code it's very basic and we've overridden the Jango user model we're now going to add a couple of things to the project that we're going to need and that's HTM X itself as well as Tailwind CSS and Daisy UI and that's going to be your for styling the web application so let's start by installing Tailwind CSS and Daisy UI I'm going to go to the daisy UI documentation and da UI is the most popular component library for ta wi CSS if we go to the documentation at the top here there's an installation page and what we can do is install this using the Tailwind plugin and we're going to see an example of that towards the end of the series but just to get up and running we're going to start by using the CDN and note the warning here CDN files are not recommended for production and that's because you can't Purge unused Styles and the file size that's shipped to your clients is going to be very large but we're going to start out by using the CDN now to get started all we need is to copy these two elements and we can paste them into our base template so if we go to the templates directory here we have this base template and here we have the title of the page within the head tag underneath that I'm going to paste these in and that is basically the link tag here for the da UI Styles and we also have the script tag for two1 CSS itself both of these are coming from a CDN but as I said we're going to change that later in the series now let's quickly test these out by adding some Tailwind styles to contacts. HTML so we have this contact manager header here I'm going to add a class attribute and let's make it bigger here by using the text 4XL class and that comes from tail and CSS and we also have text success and that is a class that's added by Daisy UI and let's add some margin bottom to the contact manager as well we can do that with the MB for class if we go back to the browser now and go to this page when we refresh the page you can see the Styles have changed we now have that text success color which is a kind of green color that we have here and the text is a bit larger as well so Tailwind is installed and it's working and so is Daisy UI let's now move on and install HTM X I'm going to go to the HTM X documentation and again there'll be links to these Pages below the video HTM X is a package that allows you to access modern browser features directly from HTML and if you want to more about that you can check out this course here it's called HDMX for beginners and that's on the net ninja website and that's going to give you a comprehensive introduction to HDMX itself and to the basic and most important features of the package now we're going to build out an application from those features so let's get started with that and let's start by installing HDMX itself now again we're going to use the CDN for HDMX at the moment later we'll move that to a build process let's go back to base. HTML and I'm going to paste that in here so we have a second script tag and that's loading HTM X version 2.0.4 so now that we've set up the application and we've added Tailwind Daisy UI and HTM X we're going to get started with building this application and we're going to do that in the next video and we're going to start by building a jangle model that's going to represent a contact in this system so we'll get to that in the next video

Original Description

In this Django with HTMX series, you'll learn how to make a contacts app using Django for the backend & HTMX for the frontend. You'll also learn how to upload files to Amazon S3 & deploy the app to Render. 🔥🥷🏼Get instant access to ALL premium courses on NetNinja.dev: https://netninja.dev/ 🔥🥷🏼Get instant access to This Course on NetNinja.dev: https://netninja.dev/p/django-htmx 📂🥷🏼 Access the course files on GitHub: https://github.com/bugbytes-io/htmx-contacthub 🧠🥷🏼HTMX for Beginners: https://netninja.dev/p/htmx-for-beginners 🔗👇 Install HTMX: https://htmx.org/docs/#installing 🔗👇 Install Daisy UI & Tailwind CSS: https://daisyui.com/docs/install/ 🔗👇 Django Storages: https://django-storages.readthedocs.io/en/latest/ 🔗👇 Render: https://render.com/ 🔗👇 Amazon S3 Storage: https://aws.amazon.com/s3/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

Related Reads

Up next
How to Speed Up Your WordPress Website with WP Rocket ⚡Tutorial 2026
Matt Tutorials
Watch →