Creating a New Django Website

Although setting up a new Django/Python website requires a few steps, it is easy to get up and running!

The first steps are below. After that, you might want to see about putting your project on github, or gitlab, and setting up Apache on Ubuntu to serve your site.

  1. Create initial folder.
  2. Create virtual environment.
  3. Install Django.
  4. Create project.
  5. Couple little modifications to skeleton files.
  6. Run commands.
  7. Initialize Git
  8. That’s It!

Create Initial Folder

First, create the root folder for your project. Something like ~/projects/demo1

$ mkdir demo1

Create Virtual Environment

$ cd demo1
$ python -m venv venv
$ . venv/bin/activate

Depending on your platform, this may not work. The bin may be placed in a scripts folder, so …

$ . venv/scripts/activate

Install Django

$ pip install django

Create Project

$ django-admin startproject demo1

Couple little modifications to skeleton files

To Template>Options in

'builtins': [

At the bottom of

STATIC_URL = '/static/'
STATIC_ROOT = 'static/' # os.path.join(BASE_DIR, STATIC_URL)

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

Run commands

$ python makemigrations
$ python collectstatic
$ python migrate
$ python createsuperuser

Initialize Git

Before initializing git, we first need to add a .gitignore file, a .gitattributes file, and a file.

$ git init
$ git add .
$ git commit -m "initial commit"


That’s it, you’re done. You are now ready to look at your site at by running:

$ python runserver

Now you can work on your project. Don’t forget to commit your changes. You should setup a repo on github, or gitlab to host your project.

You may also want to look into hosting your site. Setting up Apache on Ubuntu is a recommended way to serve your site.

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *