Skip to content

rishsv/ORM2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Ex02 Django ORM Web Application

Date: 16.09.2025

AIM

To develop a Django application to store and retrieve data from a Car Inventory Database using Object Relational Mapping(ORM).

DESIGN STEPS

STEP 1:

Clone the problem from GitHub

STEP 2:

Create a new app in Django project

STEP 3:

Enter the code for admin.py and models.py

STEP 4:

Execute Django admin and create details for 5 Car

PROGRAM

models.py
from django.db import models
from django.contrib import admin
class Car(models.Model):
    brand = models.CharField(max_length=100, help_text="Car Brand")
    model_name = models.CharField(max_length=100, help_text="Model Name")
    manufacture_year = models.IntegerField(help_text="Year of Manufacture")
    car_type = models.CharField(max_length=50, help_text="Type of Car")
    price = models.DecimalField(max_digits=10, decimal_places=2, help_text="Price in USD")
    mileage = models.IntegerField(help_text="Mileage in km per liter")
    color = models.CharField(max_length=30, help_text="Car Color")
    engine_capacity = models.DecimalField(max_digits=4, decimal_places=1, help_text="Engine Capacity in Liters")
    fuel_type = models.CharField(max_length=20, help_text="Fuel Type")
    number_of_doors = models.IntegerField(help_text="Number of Doors")
    seating_capacity = models.IntegerField(help_text="Seating Capacity")

class CarAdmin(admin.ModelAdmin):
    list_display = ('brand', 'model_name', 'manufacture_year', 'car_type', 'price','mileage', 'color', 'engine_capacity', 'fuel_type', 'number_of_doors', 'color')
    search_fields = ('brand', 'model_name', 'car_type', 'fuel_type', 'color')
admin.py
from django.contrib import admin
from .models import (Car,CarAdmin)

admin.site.register(Car,CarAdmin)
'''class CarAdmin(admin.ModelAdmin): 
    list_display = (
        'brand', 
        'model_name', 
        'manufacture_year', 
        'car_type', 
        'price', 
        'fuel_type', 
        'transmission', 
        'color', 
        'engine_capacity', 
        'mileage',
        'number_of_doors',
        'registration_number'
    )
    search_fields = ('brand', 'model_name', 'car_type', 'fuel_type', 'transmission', 'color')
    list_filter = ('brand', 'car_type', 'fuel_type', 'transmission', 'manufacture_year')
    ordering = ('brand', 'model_name')'''

OUTPUT

alt text

RESULT

Thus the program for creating car inventory database database using ORM hass been executed successfully

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%