Summary of "Django Tutorial #3 - Django Basics"

Summary of “Django Tutorial #3 - Django Basics”

This tutorial covers the foundational steps for setting up a Django project and application, focusing on creating a simple “Asia Tours Agency” management system. The video explains the project structure, key files, and how to render a basic HTTP response in the browser. It also introduces URL routing and setting up the project to run on a local server.


Main Ideas and Concepts

Project and Application Setup

Virtual Environment and Dependency Management

Django Application File Overview

Linking Application to Project

Creating a Basic View and HTTP Response

URL Routing

Running the Server

Next Steps

In future lessons, the tutorial will cover: - Creating HTML templates for rendering proper web pages. - Working with databases and migrations. - Adding models and displaying data via Django shell and browser.


Methodology / Step-by-Step Instructions

  1. Set up environment and install Django

    • Navigate to project directory: cd lesson2_django_app
    • Activate virtual environment: pnv shell
    • Install Django: pnv install django
  2. Create Django project and application

    • Create project: django-admin startproject WorldTour
    • Change directory: cd WorldTour
    • Create app: python manage.py startapp AsiaToursAgency
  3. Register the application

    • Open settings.py
    • Add 'AsiaToursAgency.apps.AsiaToursAgencyConfig' to INSTALLED_APPS
  4. Create a simple view In AsiaToursAgency/views.py:

```python from django.http import HttpResponse

def index(request): return HttpResponse(“Asia Tours Agency”) ```

  1. Set up URL routing Create AsiaToursAgency/urls.py:

```python from django.urls import path from . import views

urlpatterns = [ path(‘’, views.index, name=’index’), ] ```

Modify project urls.py:

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

urlpatterns = [ path(‘admin/’, admin.site.urls), path(‘’, include(‘AsiaToursAgency.urls’)), ] ```

  1. Run the server
    • Run: python manage.py runserver
    • Open browser at http://localhost:8000/ to see the output.

Speakers / Sources


This summary encapsulates the core lessons and instructions on starting a Django project, creating an application, understanding the project structure, setting up views and URLs, and running the development server.

Category ?

Educational

Share this summary

Video