First Django App For Beginners Part 3(templates & static files)

thisisazeez

Abdul Azeez

Posted on October 30, 2021

First Django App For Beginners Part 3(templates & static files)
For this part of tutorial we are going to be building A simple Django Booking(appointment) App!

Welcome Back!

Let's get started.
  • Start by creating a project called appointment
  • Also create a app called app
  • Register your app in your project folder
  • And do your url config.
Pls Get the template folder we are going to be using fromLink to my Github Profile

Let's Get Started!

Template and Static files Settings.

Step 1: after setting up your django application we will register our template files

Template Settings

Step 2: Static Files

Static Settings

Urls and Views

I hope you have already set up your urls if you haven't set it up to see if you can do it if you encounter any error pls comment in the comment section!

Let's get started!

1 models.py:
models.py

What is models.py:
Models.py is a file that allows us to completely define our database!

2 views.py:
views.py

What is context in our views.py:
So we imported our models in line 2 of our code and we want to show something from our database so we use context manager to help us render models to view!

3 urls.py:
urls.py

What did we do in urls.py?:
We imported our views file and used it to create our url

4 admin.py:
admin.py

What just happened in the file:
we imported our model and register it so it can be viewed in the admin site

*Introduction to Django Admin Site *
What is Django admin?
Django Has a built-in admin site that handles the site management and to log in to the admin site we need to create a superuser to do that we use this command python manage.py createsuperuser it will throw an error because you haven't make your migrations
to do that we use this command python manage.py makemigrations the command will initialize your database and then this command python manage.py migrateto create the necessary tables and columns then you can crate your super user

now crate your superuser and runserver then go to /admin

you will discover a page saying login so you enter your superuser credentials and boom a dashboard

django admin site

Add some models and play around with it
Pls Comment if you encounter any errors

Catch Ya Later!

Play Around With this Part 4 will contain user authentication and sending mails i hope we all have a great understanding of django

💖 💪 🙅 🚩
thisisazeez
Abdul Azeez

Posted on October 30, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related