Skip to content

judeaugustinej/django101

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alt tag

Django code workflow

Describes the basics steps required to get a django-app up and running.

Make sure django is installed

pip install django
pip install psycopg2

Create a django project

django-admin startproject project

The functionality of web-app can be divided into smaller apps.

cd project
python manage.py startapp app

The project the structure

project/
|-- app
|   |-- admin.py
|   |-- apps.py
|   |-- __init__.py
|   |-- migrations
|   |   `-- __init__.py
|   |-- models.py
|   |-- tests.py
|   `-- views.py
|-- db.sqlite3
|-- manage.py
`-- project
    |-- __init__.py
    |-- settings.py
    |-- urls.py
    |-- wsgi.py

Include the create app in the main settings

vi project/app.py

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

Database setup for postgres

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'db_name',                      
        'USER': 'db_user',
        'PASSWORD': 'db_user_password',
        'HOST': '',
        'PORT': 'db_port_number',
    }
}

Run migrations and start the development server

python manage.py migrate
python manage.py runserver

Create a simple view

Create route for app

Include the route

Visit the page we created.

About

Things i did while learning django

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published