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

Basics of Web Development

Web development encompasses the creation of websites and applications, divided into frontend (client-side) and backend (server-side) development. Frameworks like Django facilitate this process by providing tools and structures, while Django specifically follows the MVT architectural pattern for efficient web application development. The document outlines the steps to create a Django project, including installation, project structure, and example code for models, views, and templates.

Uploaded by

thatdumb67
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 views7 pages

Basics of Web Development

Web development encompasses the creation of websites and applications, divided into frontend (client-side) and backend (server-side) development. Frameworks like Django facilitate this process by providing tools and structures, while Django specifically follows the MVT architectural pattern for efficient web application development. The document outlines the steps to create a Django project, including installation, project structure, and example code for models, views, and templates.

Uploaded by

thatdumb67
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/ 7

Basics of Web Development:

Web Development:

Web development involves the creation of websites and web applications that run on the Internet. It can be
broken down into two main categories.

o Frontend Development (Client-Side): This focuses on the visual aspects of a website and what
users see and interact with. Technologies used include HTML, CSS, JavaScript, and jQuery.

o Backend Development (Server-Side): This deals with the server side of a website, including
databases, server logic, and APIs. Technologies used include PHP, Ruby, Java, Node.js, Python,
and databases like MySQL, MongoDB, PostgreSQL

Backend vs Frontend:

Backend Development Frontend Development


Deals with server-side operations, databases, and Focuses on the user interface and user experience.
application logic.
Uses languages like Python, Java, Ruby, PHP, and Uses HTML, CSS, and JavaScript.
Node.js.
Responsible for data storage, security, and Responsible for designing and implementing the
processing requests. layout and interactive elements.
Tools like Django, Flask, Spring, and Express. Tools like React, Angular, Vue.js, and Bootstrap.
Works with servers, APIs, and databases to fetch Sends requests to the backend and displays
and process data. responses to the user.

Framework:

A framework is a set of conceptual structures and guidelines used to build something useful. Frameworks
are software that are developed to build applications. Framework is a collection of tools designed to help
to create your project so you don’t need to start from scratch. A framework may include predefined classes
and functions that can be used to process input, manage hardware devices, and interact with system
architecture. Examples of frameworks are Angular, Laravel, Django, and Spring.

Why to use frameworks:

o No need to write code from scratch.


o Saves time.
o Inbuild security features.
o Clean code
o Reusable code
o Testing and debugging is easy.
o Lot of inbuilt tools.

Prepared by Nawaraj Prajapati (MCA From JNU)


Django:

Django is a high-level open-source Python web development framework for building websites. Most
popular Python framework. It follows the model–view–template (MVT) architectural pattern. It was created
by Adrian Holovaty and Simon Willison.

Why Django?

o It’s fast and simple.


o It’s secure.
o It suits any web application project.
o It’s well-established.
o MVT support and Object-Oriented approach.
o Built-in Authentication and Authorized.
o Provides SQLite Database by Default.

MVT:

The MVT (Model View Template) is a software design pattern. It is a collection of three important
components Model View and Template.

MVT Architecture:

Model: The model is going to act as the interface of your database. It is responsible for maintaining the
database.

View: The View is the user interface. It is the data that a user sees when a user renders a website. It works
as a mediator between the Template and the Model

Template: A template is a file where you describe how the result should be represented. It many consist of
HTML, CSS, and JavaScript.

Prepared by Nawaraj Prajapati (MCA From JNU)


How MVT Works Together:

To see how these components interact, let’s walk through a typical request-response cycle in a Django
application:

1. User Request: A user sends a request to the Django application (e.g., by entering a URL in the
browser).

2. URL Routing: Django’s URL dispatcher maps the URL to a view. This is defined in the urls.py
file, where URL patterns are matched against the incoming request.

3. View Processing: The view function or class is called. This is where the business logic is
executed. The view may query the database using Django models, perform computations, or
interact with other parts of the application.

4. Template Rendering: The view passes data to a template. The template engine processes the
template, replacing placeholders with actual data.

5. Response: The rendered HTML is returned to the user as an HTTP response.

Example:

Model: Define a Post model in models.py

from django.db import models

class Post(models.Model):

title = models.CharField(max_length=200)

content = models.TextField()

published_date = models.DateTimeField(auto_now_add=True)

def __str__(self):

return self.title
View: Create a view in views.py to display all posts.

from django.shortcuts import render

from .models import Post

def post_list(request):

posts = Post.objects.all()

return render(request, 'blog/post_list.html', {'posts': posts})

Prepared by Nawaraj Prajapati (MCA From JNU)


Template: Design a template post_list.html to render the posts.

<!DOCTYPE html>

<html>

<head>

<title>Blog Posts</title>

</head>

<body>

<h1>Blog Posts</h1>

{% for post in posts %}

<h2>{{ post.title }}</h2>

<p>{{ post.content }}</p>

<p><em>Published on {{ post.published_date }}</em></p>

{% endfor %}

</body>

</html>

How to create a Django Framework Project in Visual Studio Code:

Step 1: Install Django

o pip install Django

Step 2: go to create a folder name

o Create a folder
For example: DjangoProjectDemo

Step 3: go to the folder directory

o C:\All Programming Files\DjangoProjectDemo>

Step 4: Create a project name

o C:\All Programming Files\DjangoProjectDemo>django-admin startproject crudOperation

Step 5: go to the project folder

o C:\All Programming Files\DjangoProjectDemo>cd crudOperation


o C:\All Programming Files\DjangoProjectDemo\crudOperation>

Prepared by Nawaraj Prajapati (MCA From JNU)


Step 6: run the project

C:\All Programming Files\DjangoProjectDemo\crudOperation>python manage.py runserver

Watching for file changes with StatReloader

Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the
migrations for app(s): admin, auth, contenttypes, sessions.

Run 'python manage.py migrate' to apply them.

March 25, 2025 - 13:18:29

Django version 5.1.5, using settings 'crudOperation.settings'

Starting development server at http://127.0.0.1:8000/ copy this URL and run in browser

Quit the server with CTRL-BREAK.

Step 6: setup this thing in VS Code

o Python
o HTML CSS
o Django
o Django template
o Django snippets

Prepared by Nawaraj Prajapati (MCA From JNU)


Django Project Directory Structure:

__init__.py: The folder which contains __init__.py file is considered as Python package.

asgi.py: Stands for Asynchronous Server Gateway Interface, used for deploying asynchronous web
applications.

settings.py: The configuration file for your project (database settings, middleware, installed apps, etc.).

URLs.py: The central file where you define URL routes to connect views to specific web addresses.

wsgi.py: Stands for Web Server Gateway Interface, used for deploying WSGI-compatible web applications.

manage.py: A command-line utility to interact with your project. You use it to run the server, make
migrations, create apps, etc.

db.sqlite3: The default database file (SQLite) that Django creates to store your data. You can switch to
other databases like PostgreSQL or MySQL.

If you want to create a subfolder inside your project you can use this command:

PS C:\All Programming Files\DjangoProjectDemo\crudOperation> python manage.py startapp templates

PS C:\All Programming Files\DjangoProjectDemo\crudOperation> python manage.py startapp static

PS C:\All Programming Files\DjangoProjectDemo\crudOperation> python manage.py startapp media

PS C:\All Programming Files\DjangoProjectDemo\crudOperation>

Prepared by Nawaraj Prajapati (MCA From JNU)


Default Table we be create:

PS C:\All Programming Files\DjangoProjectDemo\crudOperation> python manage.py migrate

Showing database in table

PS C:\All Programming Files\DjangoProjectDemo\crudOperation> python manage.py createsuperuser

Username (leave blank to use 'nawarajprajapati'): admin

Email address: [email protected]

Password:

Password (again):

The password is too similar to the username.

This password is too common.

Bypass password validation and create user anyway? [y/N]: y

Superuser created successfully.

PS C:\All Programming Files\DjangoProjectDemo\crudOperation>

Prepared by Nawaraj Prajapati (MCA From JNU)

You might also like