
- 22 students
- 41 lessons
- 0 quizzes
- 10 week duration
-
Python Basics
- Installing Anaconda and running a sample Python Program
- How to use the Print function in Python?
- Arithmetic Operations in Python
- Running a Web Server using Python in Spyder
- Input Output in Python
- Starting Plots in Python
- For loop in Python
- Installing and running DJango
- Linear and Polynomial Regression using Python
- Some Problems on Lists
- Creating Classes in Python
- Inheritance in Python
- How to implement Multiple Inheritance in Python
- Using Flask-1
- Lists in Python
- Lists in Python — 1
- Sorting of Lists
- Lists in Python — Insertions
- How to make a list in python and save it in files ……
- Importing Excel Files in Python
- Mailer in Python
- How to add a simple view to a Django site?
- Python Print and I/O questions
- Print answers
- If then else in Python
- Summation of Series
- Python Print Assignment
- Loop Assignments
- Pickle in Python
- Dictionary in Python-1
- Dictionaries in Python-2
- Python OOPs Assignment
- Operator Overloading in Python
- Equation Solving using Numpy
- Starting Numpy
- Passing Data from a Python Controller to a HTML Page
- Downloading Data from a URL in Python
- Sending a Dictionary to a HTML Template and displaying it using Flask.
- Web Scraping Library-1
- Downloading data from a remote website and displaying data in an html page
- Arithmetic Operations in Python — Assignment
How to add a simple view to a Django site?
How to add a view to a DJango Site.
Create a file called views.php in the site installation under DJango.
This is the code written in the file.
views.py
from django.http import HttpResponse
def index(request):
html = “<h1>Champak View</h1>”
return HttpResponse(html)
We define a function def index(request).
This is the default function for the url. It receives an object of type HttpRequest. We are not accepting anything from the request here. We simply create a html text and return it by wrapping it in the HttpResponse.
Then we add the new url to urls.py
urls.py
from django.contrib import admin
from django.urls import path
from .views import index
urlpatterns = [
path(‘admin/’, admin.site.urls),
path(‘hoopla/’, admin.site.urls),
path(‘lafda/’, index),
path(”, index),
]
Go to the url and you can have a view.
http://127.0.0.1:8000
end