django application example

Example 1: start django project

django-admin startproject <//name of project\\>

Example 2: quick start django

pip install Django
django-admin startproject mysite
cd mysite
python manage.py runserver

Example 3: create new django app

python manage.py startapp app_name

Example 4: simple django app

# start by installing django by typing the following command

python -m pip install Django

# you can check if it worked by typing

python3 -m django --version # for mac

python -m django --version # for windows

# when that works you can start your project by

django-admin startproject your_project_name

# then you can start your first app by

django-admin startapp your_app_name

# before you can run it, you need to add the app to the project

# go to the folder your_project_name and open settings.py and scroll down until you see this

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

# then go to the folder your_app_name and open apps.py and copy the class name

# when you did that, add the following line to installed apps

'your_app_name.apps.the_class_name_you_just_copied'


# happy coding!