1. What is a Django Model?
A model is a Python class that represents a database table.
2. What is ORM in Django?
ORM (Object Relational Mapping) allows interaction with the database using Python code instead of SQL.
3. Why use ORM?
It simplifies database operations and prevents SQL injection.
4. Where are models defined?
In models.py file of an app.
5. What is a field in Django model?
A field represents a column in the database table.
6. What is primary key?
A unique identifier for each record.
7. Does Django create primary key automatically?
Yes, an auto-incrementing ID field is created by default.
8. What is AutoField?
An integer field that auto-increments.
9. What is BigAutoField?
A larger version of AutoField for big datasets.
10. What is CharField?
A field used to store short text with a max length.
11. What is TextField?
Used for storing large text data.
12. What is IntegerField?
Stores integer values.
13. What is FloatField?
Stores floating-point numbers.
14. What is DecimalField?
Stores decimal numbers with precision.
15. What is BooleanField?
Stores True or False values.
16. What is DateField?
Stores date values.
17. What is DateTimeField?
Stores date and time.
18. What is EmailField?
Stores email addresses with validation.
19. What is URLField?
Stores URLs.
20. What is FileField?
Used for file uploads.
21. What is ImageField?
Used for image uploads.
22. What is ForeignKey?
Creates a many-to-one relationship.
23. What is OneToOneField?
Creates a one-to-one relationship.
24. What is ManyToManyField?
Creates a many-to-many relationship.
25. What is related_name?
Defines reverse relationship name.
26. What is null=True?
Allows database to store NULL values.
27. What is blank=True?
Allows field to be empty in forms.
28. Difference between null and blank?
null is database-level, blank is form-level.
29. What is default value?
Value assigned if no data is provided.
30. What is unique=True?
Ensures all values are unique.
31. What is choices in field?
Defines predefined options.
32. What is verbose_name?
Human-readable name of field.
33. What is help_text?
Displays help message in forms.
34. What is db_index?
Creates index for faster queries.
35. What is ordering?
Defines default order of records.
36. What is Meta class?
Used to define model metadata.
37. What is db_table?
Specifies custom table name.
38. What is abstract model?
A model that is not created in database.
39. What is proxy model?
Changes behavior without altering database.
40. What is managed=False?
Django will not manage the table.
41. What is migration?
Process of applying changes to database.
42. What is makemigrations?
Creates migration files.
43. What is migrate?
Applies migration to database.
44. What is SQL generated by Django?
Django converts models into SQL queries.
45. What is save() method?
Saves object into database.
46. What is delete() method?
Deletes object from database.
47. What is __str__() method?
Returns string representation of object.
48. What is objects manager?
Interface to query database.
49. What is QuerySet?
A collection of database queries.
50. What is filter()?
Returns filtered results.
51. What is get()?
Returns single object.
52. What is all()?
Returns all objects.
53. What is exclude()?
Excludes specific records.
54. What is order_by()?
Sorts query results.
55. What is count()?
Returns number of records.
56. What is exists()?
Checks if records exist.
57. What is first()?
Returns first record.
58. What is last()?
Returns last record.
59. What is aggregate()?
Performs calculations like sum, avg.
60. What is annotate()?
Adds calculated fields.
61. What is select_related()?
Optimizes foreign key queries.
62. What is prefetch_related()?
Optimizes many-to-many queries.
63. What is Q object?
Used for complex queries.
64. What is F expression?
Refers to model fields in queries.
65. What is bulk_create()?
Creates multiple records at once.
66. What is bulk_update()?
Updates multiple records.
67. What is get_or_create()?
Gets or creates object.
68. What is update_or_create()?
Updates or creates object.
69. What is raw()?
Executes raw SQL queries.
70. What is transaction?
Ensures database consistency.
71. What is atomic()?
Ensures operations run as a single transaction.
72. What is database index?
Improves query performance.
73. What is unique constraint?
Ensures uniqueness.
74. What is composite key?
Combination of fields as primary key.
75. What is model inheritance?
Extending models using inheritance.
76. Types of model inheritance?
Abstract, multi-table, proxy.
77. What is multi-table inheritance?
Each model has its own table.
78. What is signals in models?
Triggers actions on model events.
79. Example of signals?
pre_save, post_save.
80. What is slug field?
SEO-friendly URL field.
81. What is UUIDField?
Stores unique identifiers.
82. What is JSONField?
Stores JSON data.
83. What is TimeField?
Stores time values.
84. What is DurationField?
Stores time duration.
85. What is Auto_now?
Automatically updates date on save.
86. What is Auto_now_add?
Sets date when object is created.
87. What is validators?
Used to validate data.
88. What is clean() method?
Custom validation method.
89. What is full_clean()?
Validates model fields.
90. What is model manager?
Custom manager for queries.
91. What is custom manager?
Custom query logic.
92. What is queryset chaining?
Combining multiple query methods.
93. What is lazy evaluation?
Query executes only when needed.
94. What is database normalization?
Organizing data to reduce redundancy.
95. What is denormalization?
Adding redundancy for performance.
96. What is indexing importance?
Speeds up queries.
97. What is migration conflict?
Occurs when multiple migrations clash.
98. How to resolve migration conflict?
Use merge migrations.
99. What is Django ORM advantage?
Database independence and security.
100. How to optimize models?
Use indexing, select_related, caching, and proper relationships.
📢 Join Our WhatsApp Channel
💼 Get Daily IT Job Updates, Interview Preparation Tips & Instant Alerts directly on WhatsApp.
👉 Join WhatsApp Now📢 Join Our Telegram Channel
💼 Get Daily IT Job Updates, Interview Tips & Exclusive Alerts directly on Telegram!
👉 Join Telegram