To develop a Django appl pythonication to store and retrieve data from a Book database using Object Relational Mapping(ORM).
Clone the problem from GitHub
Create a new app in Django project
Enter the code for admin.py and models.py
Execute Django admin and create details for 10 books
models.py
from django.db import models
from django.contrib import admin
class book_DB(models.Model):
bookno=models. IntegerField(primary_key="bookno")
bookname=models.CharField(max_length=20)
author=models.CharField(max_length=30)
pageno=models.IntegerField()
language=models.CharField(max_length=30)
class book_DBAdmin(admin.ModelAdmin):
list_display=("bookno", "bookname","author", "pageno","language");
admin.py
from django.contrib import admin
from .models import book_DB,book_DBAdmin
admin.site.register(book_DB,book_DBAdmin)
Thus the program for creating a database using ORM hass been executed successfully