django application tutorial code example

Example: 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!