Django MCQs with answers Page - 3

Dear candidates you will find MCQ questions of Django here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

S

Shyam Dubey • 1.88K Points
Master

Q. How do you import the User model in Django?

  • (A) from django.models import User
  • (B) from django.contrib.auth.models import User
  • (C) from django.auth import User
  • (D) from django.contrib.models import User

S

Shyam Dubey • 1.88K Points
Master

Q. Which field type is used to store time in Django?

  • (A) DateField
  • (B) DateTimeField
  • (C) TimeField
  • (D) HourField

S

Shyam Dubey • 1.88K Points
Master

Q. Which setting is used to define the URL for static files?

  • (A) STATIC_URL
  • (B) STATIC_PATH
  • (C) STATIC_ROOT
  • (D) MEDIA_URL

S

Shyam Dubey • 1.88K Points
Master

Q. Which model method is used to retrieve a single object by its primary key?

  • (A) get()
  • (B) filter()
  • (C) select()
  • (D) all()

S

Shyam Dubey • 1.88K Points
Master

Q. What is the purpose of verbose_name in a Django model field?

  • (A) Sets the database name
  • (B) Sets a human-readable name
  • (C) Enables search
  • (D) Applies formatting

S

Shyam Dubey • 1.88K Points
Master

Q. Which method in Django class-based views is used to handle GET requests?

  • (A) post()
  • (B) get()
  • (C) handle()
  • (D) retrieve()

S

Shyam Dubey • 1.88K Points
Master

Q. What does Django use to match a URL to a view?

  • (A) path configuration
  • (B) URL dispatcher
  • (C) template engine
  • (D) routing script

S

Shyam Dubey • 1.88K Points
Master

Q. Which of the following is a valid use of the path function in urls.py?

  • (A) path(view, url, name)
  • (B) path(urlpattern, view, name)
  • (C) path(view, name, urlpattern)
  • (D) path(name, view, url)

S

Shyam Dubey • 1.88K Points
Master

Q. What is the use of the get_absolute_url() method in a Django model?

  • (A) Returns the view name
  • (B) Returns the absolute file path
  • (C) Returns the canonical URL for an object
  • (D) Returns the object name

S

Shyam Dubey • 1.88K Points
Master

Q. Which setting should be updated when adding static files in production?

  • (A) STATICFILES_DIRS
  • (B) STATICFILES_PATH
  • (C) STATIC_ROOT
  • (D) STATIC_CACHE