0% found this document useful (0 votes)
2 views3 pages

Django App Setup Guide

This document provides a step-by-step guide to creating a Django application, covering installation of Python and Django, setting up a virtual environment, and starting a project. It includes instructions for creating an app, configuring templates and static files, defining models, and setting up views and URLs. The guide concludes with running and testing the application to ensure functionality.

Uploaded by

ddark6924
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Django App Setup Guide

This document provides a step-by-step guide to creating a Django application, covering installation of Python and Django, setting up a virtual environment, and starting a project. It includes instructions for creating an app, configuring templates and static files, defining models, and setting up views and URLs. The guide concludes with running and testing the application to ensure functionality.

Uploaded by

ddark6924
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Step-by-Step Guide to Create a Django Application (Backend &

Frontend)

1. Install Python and pip

- Download and install Python from https://python.org

- Ensure pip is included and added to PATH

- Verify installation with:

python --version

pip --version

2. Create and Activate a Virtual Environment

- python -m venv venv

- source venv/bin/activate (Linux/macOS)

- venv\Scripts\activate (Windows)

3. Install Django

- pip install django

- Verify with: django-admin --version

4. Start a Django Project

- django-admin startproject myproject

- cd myproject

5. Run the Development Server

- python manage.py runserver

- Open http://127.0.0.1:8000/ in a browser

6. Create an App

- python manage.py startapp blog

- Add 'blog' to INSTALLED_APPS in myproject/settings.py

7. Create Templates and Static Folders Inside App


- blog/templates/blog/post_list.html

- blog/static/blog/style.css

8. Configure TEMPLATES and STATICFILES in settings.py

TEMPLATES = [{

...

'DIRS': [BASE_DIR / 'templates'],

'APP_DIRS': True,

...

}]

STATIC_URL = '/static/'

STATICFILES_DIRS = [BASE_DIR / 'static']

9. Define Models and Migrate

- Define models in blog/models.py

- python manage.py makemigrations

- python manage.py migrate

10. Register Models in Admin

- In blog/admin.py, register your models

- Create superuser: python manage.py createsuperuser

- Access admin at http://127.0.0.1:8000/admin

11. Create Views, URLs and Render Templates

- Define views in blog/views.py

- Create blog/urls.py and include in project urls.py

- Use render(request, 'blog/post_list.html')

12. Load and Use Static Files in HTML

{% load static %}

<link rel='stylesheet' href='{% static "blog/style.css" %}'>


13. Run and Test Your App

- python manage.py runserver

- Visit your app routes and check functionality

You might also like