Installation and setup - 30 days of Django

Installation and setup - 30 days of Django

/ #Django


In this part, we will install and create a virtual environment, and install Django into it.

You can install Django a couple of different ways. Directly on your computer, a virtual environment, a virtual machine, Docker, etc. So there are a lot of different ways to do this. In this tutorial, we're going to stick with a virtual environment. This is really easy to get started with, and it's one of the recommended ways to do it.

A virtual environment is a little environment in your computer. When it's activated, we can install Python packages (like Django) for this environment only. It also makes it easy to maintain and deploy, because we can replicated the environment on a server and similar.

Virtual environment

So first, we can install the virtual environment using pip (a package manager for Python). Run the following command in your command line/terminal.

$ pip install virtualenv

When that's finished, we can create a new environment for our project. Let's call it "toodoo_env".

$ virtualenv toodoo_env

Great, now we have a virtual environment. Let's go into it and activate it.

$ cd toodoo_env
$ source bin/activate

Now, the name of the environment should be infront of your username in the command line. As long as the environment is activated and we use "pip", the package will only be installed for the activated environment.

Django

Finally it's time to install Django and create an empty project.

$ pip install django

This will install the latest stable version of Django and a few dependencies that Django has. Next we will create the project.

$ django-admin startproject toodoo

The "django-admin" command was made available when we installed Django.

Now, we have an empty Django project and we're ready to start digging into it tomorrow.

Table of contents

Comments

No comments yet...

Add comment

Info

Please log in to comment!

Newsletter

Subscribe to my weekly newsletter. One time per week I will send you a short summary of the tutorials I have posted in the past week.