#3 - Install and Setup django

This would be the starting point to build Wobu


3 min read

In my previous post, I shared the tech stack that will be used to build Wobu. In this post, let's take the first step of installing django.

I use pydanny's cookie cutter to install django, as it helps jumpstart development. Use it with caution though, as it comes with a lot of nuts and bolts, and sometimes it may become difficult to troubleshoot issues. Towards the end, I shall share a few points to be wary of.

Even before installing django, the zeroth step will be to install a virtual environment. The below commands are for a Windows machine, as I use that for local development.

pip install virtualenv
python --version
python<version> -m venv <virtual-environment-name>

On knowing the version of python in use, create a virtual environment accordingly and activate the same. If the python version does not work, just give without the version or simply python3

The next step is to use cookiecutter, and create a django project.

pip install "cookiecutter>=1.7.0"
cookiecutter https://github.com/cookiecutter/cookiecutter-django

Below is what I used to create my project

Hooray โœจ Job done! Let's now look at a few points to keep in mind while using cookie cutter.

  1. I'd suggest doing some reading upfront on the choices you will make before you run the above command. For example, if you are new to celery, and unsure whether you'll need it or not, do some quick reading and decide whether you may need it or not. The reason is, based on the choices we make, cookiecutter will add that many entries in the settings/base.py file. If something is unnecessary, then why add it in the first place, isn't it?

  2. When you now try to run

     python manage.py runserver

    It will throw a lot of errors on missing packages and modules. You need to check one by one and install them in your virtual environment. Most of the packages will not be installed by default. Set aside half an hour to an hour to bring the server up without any hiccups.

  3. Keep in mind that we will not have settings.py like how it is when we create a django project using

     django-admin startproject <projectname>

    Instead, it will be

    This path will be used in configuration files and in code while we access values from base.py. So, do remember the path ๐Ÿ’ก

  4. It creates the users app by default under the following folder path. If you are using cookiecutter for the first time, pay attention to this one.

  5. AUTH_USER_MODEL, LOGIN_REDIRECT_URL, LOGIN_URL will be set by default in base.py. If you name your User model as something else, say CustomUser then make sure to change it in base.py. Likewise, if you do not use django authentication for login, then LOGIN_REDIRECT_URL may not come into play at all. You need to handle it yourself.

These are a few points to keep a tab on when you get started. I shall share other properties as and when we get there.

Ooh hoo ๐ŸŽŠ, the wheels are in motion ๐Ÿ›ด