Models are Djangos’ way of structuring data, data is accessed and managed using models, think of it as titles for table columns. A model is basically a class, and the attributes are field names, each field has a specific type of data, here are the most common:
Records are instances of the models, to keep them you have to use record.save()
, for real code examples visit Mozilla, and look under ‘Defining the LocalLibrary Models’
To modify the database from the interface, we need some kind of special access, this can be handled easily using admin app, first the models have to be registered (added) by importing them to admin.py
file then using admin.site.register(model name)
to register them.
Once the models are registered you can create a super user using python3 manage.py createsuperuser
in the terminal of the root, you will be prompted to define a user name an a password to home, now the user can visit the admin page and start modifying the data.