Skip to content

Instantly share code, notes, and snippets.

@chayandatta
Created March 26, 2022 05:47
Show Gist options
  • Save chayandatta/44a2689b6b113e27c013e3c0def17935 to your computer and use it in GitHub Desktop.
Save chayandatta/44a2689b6b113e27c013e3c0def17935 to your computer and use it in GitHub Desktop.
Django Steps

First activate virtual env, common choice is to call it .venv

python3 -m venv <.venv> source .venv/bin/activate

It'll show something like this in terminal, which means venv is activated

(.venv)>

Now inside the virtual env activated window, install django/drf

pip install django djangorestframework

Add 'rest_framework' to your INSTALLED_APPS setting.

INSTALLED_APPS = [
    ...
    'rest_framework',
]

Create a project

django-admin startproject <project_name> .

Start the server

python3 manage.py runserver

Create a folder apps

mkdir apps

create an app folder with app_name inside apps folder

cd apps mkdir <app_name>

Now go back to where manage.py is

cd ../../

Create apps structure on that folder

django-admin.py startapp <app_name> ./apps/<app_name>

Or from the apps folder we can create an app structure

go to apps folder

cd apps

create new app by accessing manage.py

python ../manage.py startapp <app_name>

database makemigrations

python3 manage.py makemigrations

migrate the migration files

python3 manage.py migrate

exit the virtual env

(.venv) > deactivate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment