PVK Module - 3 FSD
PVK Module - 3 FSD
PVK Module - 3 FSD
3.Add the admin URL pattern: Ensure your urls.py includes the admin URL
pattern.
Logging In
The admin interface starts with a login screen where you use your super user
credentials.
Main Index Page
• listing all objects with an Admin declaration.
• You can manage users, groups, and permissions from this page.
Change Lists and Edit Forms
Change Lists: These are index pages for objects, showing a list of entries. You can
customize which fields appear and add features like search fields and filters.
Edit Forms: Used to create and modify objects, these forms show fields defined in
your model with appropriate widgets for each field type
(e.g., date pickers for date fields).
Input Validation
The admin interface includes input validation,
highlighting errors if required fields are left blank or
invalid data is entered.
Object History
Each object has a History button to view a log of
changes made through the admin interface.
Deletion Confirmation
Deleting an object requires confirmation. The
interface shows all related objects that will also be
deleted to prevent accidental data loss.
Managing Users, Groups, and Permissions
Example: At a newspaper, a reporter enters data about a special report through the
admin interface while developers work on the feature’s frontend.
2.Inspecting Data Models:
Initial Testing: When a new model is defined, developers use the admin interface to enter dummy data.
This helps quickly identify and correct data modeling mistakes by providing a graphical representation of the
model.
• Example: A site like chicagocrime.org, which collects data automatically, can use the admin interface to
correct errors in the acquired data.
BENEFITS OF ADMIN INTERFACES
• Ease of Use: It is designed for nontechnical users,
making it easy for content producers to manage data
without needing technical skills.
from django.core.mail import send_mail send_mail( 'Feedback from your site, topic: %s' % topic, message,
sender, ['[email protected]'] )
After sending the email, redirect the user to a confirmation page to inform them that their feedback has been
submitted successfully.
Use of Post() Request()method in python
import requests
url='https://www.w3schools.com/python/demopage.php'
myobj = {'somekey': 'somevalue'}
x = requests.post(url, json = myobj)
print(x.text)
requests.get(url, timeout=2.50)
API in General
• APIs are mechanisms that enable two
software components to communicate with
each other using a set of definitions and
protocols.
• For example, the weather bureau's software
system contains daily weather data. The
weather app on your phone “talks” to this
system via APIs and shows you daily weather
updates on your phone.
Application Programming Interface
Including Other URLconfs
• include() function to manage URLs across different
applications or modules.
1. Purpose of include():
• Behavior:
• When Django encounters include(), it removes the part of
the URL that matched up to that point and passes the
remaining string to the included URLconf for further
processing.
• The DRY principle emphasizes the importance of writing modular, reusable code and avoiding repetition wherever
possible.
• Django's URL dispatcher: It allows you to define URL patterns and map them to corresponding views.
• Template system: Django's template language supports template inheritance, allowing you to define base templates
that contain common elements shared across multiple pages.
• Model inheritance: Django's object-relational mapping (ORM) supports model inheritance, enabling you to define
common fields and behaviors in a base model and derive specialized models from it.
• Middleware: Django's middleware framework lets you define reusable components that process requests and
responses.
• Middleware can be used to handle common tasks such as authentication, session management, and caching,
eliminating the need to repeat the same logic in multiple views.
Module -4
Generic Views
• Use generic views:
• Less code is better These views represent a
common case of basic Web development:
• getting data from the database according to a
parameter passed in the URL.
• loading a template and returning the rendered
template.
• Generic views abstract common patterns to the
point where you don’t even need to write Python
code to write an app