To develop a Django application to store and retrieve data from a database using Object Relational Mapping(ORM).
An Django application is created inside dataproject folder.
A python program is written to create a table to store and retrieve data.
The table is created with 6 fields in which the username field is made as PrimaryKey.
Then the project files migrated. A superuser is also created.
Now the server side program is executed .
The admin page of our website is accessed using username and password.
Records are added and saved in the table inside the database.
Write your own steps
from django.db import models
from django.contrib import admin
# Create your models here.
class Database(models.Model):
Patient_id = models.CharField(max_length=8, primary_key=True ,help_text="Your Patient id")
Patient_name = models.CharField(max_length=100)
Patient_age = models.IntegerField()
email = models.EmailField()
Contact_number = models.IntegerField()
class PatientAdmin(admin.ModelAdmin):
list_display = ('Patient_id','Patient_name','Patient_age','email','Contact_number')
Thus a Django application is successfully developed to store and retrieve data from a database using Object Relational Mapping(ORM).