Q. Which file contains the list of installed apps in a Django project?

  • (A) apps.py
  • (B) init.py
  • (C) settings.py
  • (D) manage.py
πŸ’¬ Discuss
βœ… Correct Answer: (C) settings.py
Explanation: The list of installed apps is located in `settings.py` under the `INSTALLED_APPS` variable.

Q. What is the default database used by Django?

  • (A) MySQL
  • (B) PostgreSQL
  • (C) Oracle
  • (D) SQLite
πŸ’¬ Discuss
βœ… Correct Answer: (D) SQLite
Explanation: Django uses SQLite by default for development because it's lightweight and requires no setup.

Q. Which of the following handles HTML output in Django?

  • (A) Model
  • (B) Template
  • (C) View
  • (D) Admin
πŸ’¬ Discuss
βœ… Correct Answer: (B) Template
Explanation: Templates are used to generate HTML in Django.

Q. Which function is used to render HTML in Django views?

  • (A) display()
  • (B) send()
  • (C) render()
  • (D) html()
πŸ’¬ Discuss
βœ… Correct Answer: (C) render()
Explanation: The `render()` function combines a template with a context dictionary and returns an HttpResponse.

Q. Django ORM stands for:

  • (A) Object-Relational Mapping
  • (B) Open Resource Mapping
  • (C) Object-Relationship Model
  • (D) Outer Relational Method
πŸ’¬ Discuss
βœ… Correct Answer: (A) Object-Relational Mapping
Explanation: ORM is a technique used to interact with the database using Python objects.

Q. What command is used to create migrations for changes in models?

  • (A) python manage.py migrate
  • (B) python manage.py makemigrations
  • (C) python manage.py update
  • (D) python manage.py build
πŸ’¬ Discuss
βœ… Correct Answer: (B) python manage.py makemigrations
Explanation: `makemigrations` generates migration files based on model changes.

Q. Which of these is a Django template tag?

  • (A) {{ variable }}
  • (B) {% if %}
  • (C) {# comment #}
  • (D) <% for %>
πŸ’¬ Discuss
βœ… Correct Answer: (B) {% if %}
Explanation: Template tags in Django use the `{% %}` syntax for logic like conditions and loops.

Q. Django admin site is enabled by:

  • (A) Adding admin.py to models
  • (B) Including 'django.contrib.admin' in INSTALLED_APPS
  • (C) Using `admin.run()` in views
  • (D) Registering templates in admin.html
πŸ’¬ Discuss
βœ… Correct Answer: (B) Including 'django.contrib.admin' in INSTALLED_APPS
Explanation: To enable Django’s admin interface, 'django.contrib.admin' must be included in INSTALLED_APPS.

Q. Which function is used in Django models to define a string representation?

  • (A) __print__
  • (B) __str__
  • (C) __name__
  • (D) __display__
πŸ’¬ Discuss
βœ… Correct Answer: (B) __str__
Explanation: The `__str__` method in models defines the string representation of an object.

Q. How do you define a URL pattern in Django?

  • (A) route()
  • (B) url()
  • (C) path()
  • (D) map()
πŸ’¬ Discuss
βœ… Correct Answer: (C) path()
Explanation: Django 2.0+ uses the `path()` function in urls.py to define URL patterns.