Introduction

This entry aims to collect all the helpful command that I always forget, but are essential to build a django project from scratch.

We’ll assume that you have Django installed already and you have strong knowledge of python. More concretely python v3.x.

The information showed here has been taken from the official Django webpage

Index

1 create the site

2 Run the server

3 Create an app

4 Collect static

5 Data base operations

Create site

source: https://docs.djangoproject.com/en/1.11/intro/tutorial01/

$ django-admin startproject mysite

run the server

source: https://docs.djangoproject.com/en/1.11/intro/tutorial01/

$ python manage.py runserver

create an app

source: https://docs.djangoproject.com/en/1.11/intro/tutorial01/

$ python manage.py startapp app

Collect static

The first time that I created any static file in my project, I thought that it was enough. I was wrong, you have to run the following script to move either the new and modified static files to the path defined in your config file.

python3 manage.py collectstatic --settings "project.settings"

Database operations

I always forget what are the scripts to migrate any change in database.

  1. Make migration
python manage.py makemigrations <appname>
  1. Migrate from specified point number
python manage.py sqlmigrate <appname> 000x
  1. Check for any problem in your project
python manage.py check
  1. Migrate all changes executing the SQL sentences
python manage.py migrate