To develop a Django application to store and retrieve data from a Railway 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 records
''' admin.py
from django.contrib import admin from .models import railway,railwayAdmin admin.site.register(railway,railwayAdmin)
models.py
from django.db import models from django.contrib import admin class railway (models.Model): train_code=models.CharField(max_length=20,help_text="railway train_code")(primary_key=True) train_name=models.CharField(max_length=100) start_time=models.IntegerField() End_time=models.IntegerField() start_station_code=models.IntegerField() end_station_code=models.IntegerField()
class railwayAdmin(admin.ModelAdmin):
list_display=('train_code','train_name','start_time','End_time','start_station_code','end_station_code',)
'''
Thus the program for creating a database using ORM hass been executed successfully