Tutorial by Examples

Generally, each model maps to a single database table.We to write the field type,limits,size,etc in model.py file of the app. This will create the necessary table and fields in the database. ''' models.py ''' from django.db import models class table_name(models.Model): fie...
A Django model typically refers to a table in the database, attributes of that model becomes the column of that table. In more of a real-world example, you would create a model for any entity in your application, and store its attributes with django fields which automatically handles data-types conv...
A simple example would be for a library management application; you would have 2 models, for example, student and book in models.py: from django.db import models class student(models.Model): roll_no = models.IntegerField(primary_key=True) first_name = models.CharField(max_length=30) ...

Page 1 of 1