Django models
- It’s basically a class that replace a table or collection in the database.
-
Django web framework follows the MVC (model-view-control) pattern. -Django access and manage data through Models. models are python objects.
- model defines the structure of data.
- model is also independent of underlying data
- model acts like an API
- Django handles the communication between code and database
Fields
Fields are like database attributes, filed definition includes name and type.
Methods
methods like create, update, delete and search etc are used to communicate with data in database.
run database migration
so to add models to database.
Django admin site
Can use Django models to automatically build a site area to create, view, update and delete records.
register models
register before can be used.
create a superuser
can do everything with data.
logging and use site
There is a GUI for you to play with data fields.
- list views
- detail views
ModelAdmin
to change how a model is displayed in the GUI.