MVT (Model-View-Template) architecture is the foundation of Django. A software design pattern for creating web applications is called MVT. The following three entities make it up:
- Model
- View
- Template
Model: The model serves as the data’s interface. It is in charge of data maintenance. It is represented by a database and serves as the logical data structure for the whole application (like Sqlite, MySql, and Postgres). In a Django application, a model is an object that specifies the data’s organizational structure. It provides a variety of ways to add, update, read, and remove data from the database in order to maintain the data for the entire application.
View: A view is where we insert the application’s business logic. The view is a Python function that executes some business logic and provides the user with a response. This answer might be a 404 error, a web page(HTML page), or a redirect to another view function. The Django app’s views.py file contains all of the view functions.
Django View Simple Example
def view_example(request):
message=”Hello,This a simple view example”
context={‘message’:message}
return render(request,’app/example.html’,context)
Template: Using its template system, Django offers a straightforward way to produce dynamic HTML pages. We can create dynamic web pages using the Django template engine, which allows us to decouple the design from the Python code. We must include a few items in the settings.py file in order to configure the template system.
StudySection gives an opportunity to beginners and experts in .NET framework to go through StudySection’s .NET Certification Exam and get a .NET certification for enhancement of career in programming. If you have knowledge of the .NET framework then you can get a certificate through an online exam at StudySection.