Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Django Interview Questions and Answers

Question: Explain ORM in Django.
Answer:

ORM stands for Object-relational mapper, a special feature tool of Django. This tool helps developers to interact with the database in a more Python-esque way. It acts as the abstraction between the models and the database, where the main data is stored.

Using ORM, you can retrieve, save, and delete the data from a database without the need to write any SQL code for it. This tool will help eliminate many loopholes since it lets you maintain control over your code, and is developed in Python.

It does not matter whether the Database is a SQLite, MySQL, Postgre or Oracle the ORM makes sure that the developer writes the same code for all databases.

Django uses the ORM known as Django ORM, it uses classes inherited from models.Modle, to create tables under any database.

The only thing we need to tweak is the database settings in the setting.py file.

DATABASES = {    'default': {        'ENGINE': 'django.db.backends.postgresql',         'NAME': 'DB_NAME',        'USER': 'DB_USER',        'PASSWORD': 'DB_PASSWORD',        'HOST': 'localhost',          'PORT': '5432',    }}
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook