Please enable JavaScript.
Coggle requires JavaScript to display documents.
Django, terminal/commands, model example, doing an action on a website we…
Django
url
View
Model
-
mediator (middle ware and data handler) between the website interface and the database
implements the logic for the application
logical file structure of the project
def of how the data formats as coming from the view
Creation
Model in Django is a class imported from the django.db library that acts as the bridge between your database and server
-
contains the UI logic contains the parts like HTML CSS ..
UI is created from the Model component (content filling the UI)
-
-
-
model example
student model
terminal
create the app
django-admin startapp sstudent
install the app on our project by adding it in settings.py
INSTALLED_APPS = [
...,
'student',
]
models.py
from django.db import models
class Student(models.MODEL):
roll_no = models.TextField()
name = models.TextField(max_length = 40)
doing an action on a website we are actually sending information to the controller which then transfers tit to the models which in turn applies business logic on it and stores in the database
-
-
example login page
accessing the login page happens without the need of data . View process the request and send to the URI
entering creds .. these data (request) is sent to the view .. this time the request needs model and data is given to the model which reads and verifies data withe the connected database
if matches >> relevant data is given back to the Views which formats the data in response and send it back to the clinet