setting up django code example

Example 1: start django

pip install django # Install Django Packages
django-admin startproject project_name # Create a Project
cd project_name
python manage.py makemigrations # Create new migrations
python manage.py migrate # Apply Migrations
python manage.py createsuperuser # Create User for admin
python manage.py runserver # Start Server

python manage.py startapp sub_module # Create a sub app

Example 2: starting server in django

# to start a django server cd to dir with manage.py file and type following
python manage.py runserver

Example 3: how to install django on windows

INSTALLING PYTHON DJANGO ON WINDOWS
====================================
Application Case: Hotmessages.com app

1 - Download and install python

2 - Create a dirctory in drive C for your python project

3 - Open Windows Command Prompt

4 - Navigate and change directory to your python project folder

5 - Then Type the below commands, press enter key after each command;
    c:\>py -m venv env
    c:\>env\Scripts\activate

6 - After typing the commands, the prompt will to the below with (env) in front of c:\
    (env) C:\python-django>

7 - Then type the below command
    (env) C:\python-django>pip install django

8 - After django has finsihed insalling, type the below command to start a new project
    (env) C:\python-django>django-admin startproject hotmessages

9 - Change directory to project folder as below
    (env) C:\python-django>cd hotmessages

10 - Then type the below command
    (env) C:\python-django>python manage.py migrate

10 - Create a super user the controls main login
    (env) C:\python-django>python manage.py createsuperuser

11 - Provide your username and password to proceed

12 - Run python server to see your application
    (env) C:\python-django>python manage.py runserver

13 - Check Application running via http://127.0.0.1:8000, type this link on your browser

14 - Check the Admin Section via http://127.0.0.1:8000/admin, type this link on your browser

15 - Create your app by typing the code below
    (env) C:\python-django>python manage.py startapp hotmessages_app
    
*Important things to do
(1) Ensure your add your app directory name in the settings folder as below
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'my_new_app',
]
    
 Hope this helps
 From;
 
 - Atsu Emmanuel
 [email protected]

Example 4: create django project

$ django-admin startproject mysite

Example 5: quick start django

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

Example 6: pip install django

$ python -m pip install Django