Skip to content

Set Up Django Base Project

Terminal window
# Use git clone on bash terminal to clone repository
git clone https://github.com/darideveloper/django-base.git

On root you’ll find .env.example and .env.dev.example files, you can use them as template to create your own environment files, just remove .example from its name and fill the values.

Terminal window
python -m venv venv

Activate virtual environment (on windows)

Terminal window
venv\Scripts\activate

Activate virtual environment (on linux)

Terminal window
source venv/bin/activate

Deactivate virtual environment

Terminal window
deactivate
Terminal window
pip install -r requirements.txt

You can create your database from pgadmin or psql.

In case you want to use psql, access to postgres on terminal

Terminal window
psql postgres

Create database

Terminal window
CREATE DATABASE database_name;

Update database credentials on .env.dev files

.env.dev
...
DB_HOST=server ip
DB_PORT=db free port
DB_NAME=db name
DB_USER=db username
DB_PASSWORD=db password
...

6.2 Run migrations and create superuser to check connection

Section titled “6.2 Run migrations and create superuser to check connection”

Run migrations and create superuser

Terminal window
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser

Run project in local to check admin login

Terminal window
python manage.py runserver

Enter to localhost:8000/admin and access with admin credentials

In case you need to import fixtures, you can use the following command:

Terminal window
python manage.py loaddata

NOTE: YOU CAN FIN THIS REPOSITORY AT: https://github.com/darideveloper/django-base