By | 6 Oktober 2021

This tutorial is adapted from the Youtube channel Programming with Mosh (https[:]// Here are the easy steps to setup django.

1. Make sure python is installed on your computer (recommended using version 3)

2. Install pipenv, a management library in Python that combines pip and virtualenv:
$ pip3 install pipenv

3. For writing codes, you can use anything. In this tutorial I use Visual Studio Code.

4. Create a new directory for your first project:
$ mkdir /zdata/Workspace/python_ap/storefront

5. Go to the directory you just created, then install Django:
$ cd /zdata/Workspace/python_ap/storefront
$ pipenv install django

If successful, 2 files will appear in the project directory, namely: “Pipfile” and “Pipfile.lock”.

6. Open Visual Studio Code, to view the contents of the directory and files:
$ code .

7. Return to the console screen. To activate the virtual environment type the following command line:
$ pipenv shell

8. Create a django project:
$ django-admin startproject storefront .
Added a “.” at the end of the command line is useful for telling django that the project was created in the current directory.
If successful, the django project structure will be created in the form of a directory called “storefront” and a file called “”.

9. Run the django server, with the following command line:
$ python runserver
To run a django server with a specific port (eg port 9000) you can use the command:
$ python runserver 9000

So far, we have successfully set up our django project to show up in the browser. Hope it is useful.


  • Disable django project virtual environment:
    $ deactivate
  • Print a list of virtual environments:
    $ pipenv --venv
  • Re-enable a deactivated django project virtual environment:
    $ cd /home/juwarto/.local/share/virtualenvs/storefront-fsz7apxW
    $ source bin/activate

    Or directly with the command:
    $ . /home/juwarto/.local/share/virtualenvs/storefront-fsz7apxW/bin/activate
  • Once the virtual environment is reactivated, the django server can run as usual.
  • To keep the django server running perfectly (with data), don’t forget to run the migration before running the server.
    $ python migrate

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan.