Q. Which signal is triggered just after a model instance is saved?

  • (A) pre_save
  • (B) model_saved
  • (C) post_save
  • (D) after_commit
πŸ’¬ Discuss
βœ… Correct Answer: (C) post_save
Explanation: `post_save` signal is sent at the end of the save() method.

Q. Which of the following is used to handle file uploads in Django?

  • (A) FileHandler
  • (B) FileUploadField
  • (C) FileField
  • (D) UploadField
πŸ’¬ Discuss
βœ… Correct Answer: (C) FileField
Explanation: `FileField` is used to upload files in Django models.

Q. What will `{{ value|default:'N/A' }}` do in a template?

  • (A) Always return 'N/A'
  • (B) Set value to 'N/A'
  • (C) Return 'N/A' if value is undefined or None
  • (D) Throws error for empty value
πŸ’¬ Discuss
βœ… Correct Answer: (C) Return 'N/A' if value is undefined or None
Explanation: `default` is a filter that returns the default value if the original is undefined or None.

Q. Which file is responsible for routing URLs to views?

  • (A) views.py
  • (B) urls.py
  • (C) apps.py
  • (D) settings.py
πŸ’¬ Discuss
βœ… Correct Answer: (B) urls.py
Explanation: The `urls.py` file defines URL routing to views.

Q. Which method in a class-based view handles GET requests?

  • (A) get_object()
  • (B) fetch()
  • (C) get()
  • (D) read()
πŸ’¬ Discuss
βœ… Correct Answer: (C) get()
Explanation: The `get()` method in class-based views is called to handle HTTP GET requests.

Q. Which built-in class helps you create list views in Django?

  • (A) ListView
  • (B) ObjectView
  • (C) QueryView
  • (D) DataView
πŸ’¬ Discuss
βœ… Correct Answer: (A) ListView
Explanation: `ListView` is a class-based view for displaying a list of objects.

Q. In Django, which is used to group multiple models logically?

  • (A) Project
  • (B) App
  • (C) Field
  • (D) View
πŸ’¬ Discuss
βœ… Correct Answer: (B) App
Explanation: An app is a Python package in a Django project that contains models, views, templates, etc.

Q. Which environment variable is set to define the Django settings module?

  • (A) DJANGO_ENV
  • (B) DJANGO_SETTINGS
  • (C) DJANGO_CONF
  • (D) DJANGO_SETTINGS_MODULE
πŸ’¬ Discuss
βœ… Correct Answer: (D) DJANGO_SETTINGS_MODULE
Explanation: `DJANGO_SETTINGS_MODULE` tells Django which settings file to use.

Q. What is the correct way to import the `HttpResponse` class?

  • (A) from django.http import HttpResponse
  • (B) import HttpResponse
  • (C) from django.response import HttpResponse
  • (D) import response.HttpResponse
πŸ’¬ Discuss
βœ… Correct Answer: (A) from django.http import HttpResponse
Explanation: The correct import is `from django.http import HttpResponse`.

Q. Which of the following is used to cache data in Django?

  • (A) django.store
  • (B) django.buffer
  • (C) django.cache
  • (D) django.memory
πŸ’¬ Discuss
βœ… Correct Answer: (C) django.cache
Explanation: The `django.core.cache` framework is used for caching in Django.