To develop a Django application to store and retrieve data from a database using Object Relational Mapping(ORM).
Clone the git repository from github
Create an admin interface for Django
Create an app and edit the settings.py
Makemigrations and migrate the changes
Create admin user and write python code for admin and models
Make all the migrations to 'myapp'
Create an employee table to fit 5 fields using runserver command
admin.py:
from django.contrib import admin
from .models import Student,StudentAdmin,Employee,EmployeeAdmin
admin.site.register(Student,StudentAdmin)
admin.site.register(Employee,EmployeeAdmin)
models.py:
from django.db import models
from django.contrib import admin
class Student (models.Model):
referencenumber=models.CharField(max_length=20,help_text="reference number")
name=models.CharField(max_length=100)
age=models.IntegerField()
email=models.EmailField()
class StudentAdmin(admin.ModelAdmin):
list_display=('referencenumber','name','age','email')
class Employee (models.Model):
emp_id=models.CharField(primary_key=True,max_length=4,help_text='Employee ID')
ename=models.CharField(max_length=50)
post=models.CharField(max_length=20)
salary=models.IntegerField()
class EmployeeAdmin(admin.ModelAdmin):
list_display=('emp_id','ename','post','salary')The program for creating an employee database using ORM is executed successfully

