Since this course is targeted towards a more advanced audience, we’re going to jump into Django. If you’d like to learn more about Flask instead, watch the last chapter of the Intermediate Python Course on Frontend Masters, or review the final exercise.
We’re going to work on a basic blog that’ll help you understand the basic concepts of Django.
Instead of starting from scratch, let’s start with a project that already has an app, which is the foundation we need to work on our blog.
If you need to start a new Django project from scratch, I recommend following the steps on the official Django tutorial for building your first app.
Go to your home or project directory, and git
clone the files for our Django blog. Not comfortable with git
? Download the files instead.
$ cd ~
$ git clone https://github.com/nnja/practical_blog.git
$ cd practical_blog
Let’s create and activate a brand new virtual environment for our Django blog.
Take a look at the requirements.txt
file, it contains a (short) list of dependencies for this project.
We’re going to install these dependencies in our newly created virtual environment with the pip install -r
command.
Note, if you’re already in a virtual environment, type deactivate
or open a new terminal window.
$ python -m venv env
$ source env/bin/activate
(env) $ python -m pip install -r requirements.txt
Next, we’ll need to create the database and database tables. We’ll do this with the migrate command.
(env) $ python manage.py migrate
Finally, run the server:
(env) $ python manage.py runserver
Your site should now be available at http://localhost:8000/