1️⃣ 🏠 Getting Started with Django
Estimated reading: 3 minutes 28 views

🏠 Django Home / Introduction / Get Started

🧲 Introduction – What is Django?

Django is a high-level Python web framework designed to promote rapid development and clean, pragmatic design. It takes care of much of the hassle in web development, allowing developers to focus on writing their apps instead of reinventing the wheel.

🎯 Django offers:

  • A powerful ORM for database interaction
  • A robust templating engine
  • URL routing
  • Integrated admin interface
  • Built-in security features

Examples of major Django users include Instagram, Pinterest, Disqus, and The Washington Post.


🛠️ Why Use Django?

🔹 Batteries-Included: Everything from user authentication to RSS feeds is included.
🔹 Scalable: Used by high-traffic sites like Instagram.
🔹 Secure: Helps developers avoid common security mistakes.
🔹 Flexible & Maintainable: Encourages best practices and clean separation of concerns (MVT).


🧰 Setting Up Django

📌 1. Install Python

Ensure Python 3 is installed. Verify with:

$ python --version

If not installed, download it from python.org.

📌 2. Install pip (Python Package Installer)

Check with:

$ pip --version

🧪 Create a Virtual Environment

Use venv to isolate dependencies:

$ python -m venv env_orders

Activate it:

# Windows
$ env_orders\Scripts\activate

# macOS/Linux
$ source env_orders/bin/activate

⚙️ Install Django

Inside the virtual environment:

(env_orders) $ pip install django

Verify:

(env_orders) $ django-admin --version

🚀 Create a Django Project

Use the django-admin tool:

(env_orders) $ django-admin startproject pr_orders

Start the development server:

(env_orders) $ cd pr_orders
(env_orders) $ python manage.py runserver

Visit http://localhost:8000 to see the Django welcome page.


🧱 Create Your First Django App

Navigate to your project folder and run:

(env_orders) $ python manage.py startapp app_orders

🧩 Basic Folder Structure

env_orders/
│
├── pr_orders/           # Django project root
│   ├── settings.py      # Configuration
│   ├── urls.py          # Project-level URLs
│   └── ...
│
└── app_orders/          # Your Django app
    ├── models.py        # Data models
    ├── views.py         # Business logic
    ├── templates/       # HTML templates
    ├── urls.py          # App-level URLs
    └── ...

🌐 Add a Homepage (View + URL + Template)

views.py

from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, world. Welcome to Django!")

urls.py (app_orders/urls.py)

from django.urls import path
from . import views

urlpatterns = [
    path('', views.index, name='index'),
]

urls.py (project/pr_orders/urls.py)

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('', include('app_orders.urls')),
    path('admin/', admin.site.urls),
]

Visit: http://localhost:8000 ➝ Displays: “Hello, world. Welcome to Django!”


📌 Summary – Recap & Next Steps

🔍 Key Takeaways:

  • Django simplifies web development with a clean MVT architecture.
  • Virtual environments isolate dependencies per project.
  • The Django admin and development server are ready out-of-the-box.

⚙️ Real-World Relevance:
Mastering these fundamentals prepares you to build scalable, secure web apps quickly using Django.

Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

Django Home/Introduction/Get Started

Or Copy Link

CONTENTS
Scroll to Top