Admin Questions with Answers

7 practice questions on Admin (Django) with answers and step-by-step solutions. Try 7 samples below, then practise all 7 free in the AptiNest app.

Sample questions

Question 1Easy

Which ModelAdmin option shows columns in the change list?

  1. columns
  2. show_fields
  3. list_display
  4. display_list

Answer: C. list_display

Explanation

Others include list_filter, search_fields and ordering.

Step-by-step solution

  1. Set list_display.
  2. Columns appear.

Why the other options are wrong

  • A. columns is not a valid option here; the correct choice is list_display.
  • B. show_fields is not a valid option here; the correct choice is list_display.
  • D. display_list is not a valid option here; the correct choice is list_display.

Question 2Easy

Which file registers a model in the admin site?

  1. admin.py
  2. models.py
  3. views.py
  4. urls.py

Answer: A. admin.py

Explanation

Use admin.site.register(Post) or the @admin.register decorator.

Step-by-step solution

  1. Open admin.py.
  2. Register.

Why the other options are wrong

  • B. Models define data.
  • C. Views handle requests.
  • D. URLs route.

Question 3Easy

Which command creates a user who can log in to the admin site with all permissions?

  1. python manage.py createsuperuser
  2. python manage.py addadmin
  3. python manage.py createadmin
  4. python manage.py adduser --admin

Answer: A. python manage.py createsuperuser

Explanation

createsuperuser sets is_staff and is_superuser.

Step-by-step solution

  1. Createsuperuser command sets is_staff and is_superuser.
  2. These flags allow login to admin site with all permissions.
  3. Other commands do not set both flags correctly.
  4. Thus, createsuperuser is the correct command.
  5. Final answer: python manage.py createsuperuser.

Why the other options are wrong

  • B. addadmin is not a Django command; createsuperuser sets the staff and superuser flags.
  • C. createadmin is not a built-in Django command; the built-in one is createsuperuser.
  • D. adduser has no --admin flag in Django; a superuser is made with createsuperuser.

Tip: Remember: createsuperuser gives all permissions for Django admin.

Question 4Easy

Which command creates an admin login?

  1. python manage.py createadmin
  2. python manage.py createsuperuser
  3. python manage.py adduser
  4. python manage.py makeuser

Answer: B. python manage.py createsuperuser

Explanation

It prompts for username, email and password.

Step-by-step solution

  1. Run command.
  2. Visit /admin/.

Why the other options are wrong

  • A. python manage.py createadmin is not a Django management command; the correct choice is python manage.py createsuperuser.
  • C. python manage.py adduser is not a Django management command; the correct choice is python manage.py createsuperuser.
  • D. python manage.py makeuser is not a Django management command; the correct choice is python manage.py createsuperuser.

Question 5Easy

Which file in an app is conventionally used to register models with the admin site?

  1. admin.py
  2. models.py
  3. apps.py
  4. views.py

Answer: A. admin.py

Explanation

Use admin.site.register or the @admin.register decorator.

Step-by-step solution

  1. Admin site registration uses the admin module in Django.
  2. The admin.py file contains functions to register models with the admin site.
  3. Using admin.site.register is the standard way to link models to the admin interface.
  4. This makes the model visible in the Django admin panel for management.
  5. Therefore, the correct file is admin.py.

Why the other options are wrong

  • B. models.py defines the data models; it is not where admin registration is conventionally done.
  • C. apps.py holds the app's configuration class, not admin registration.
  • D. views.py holds request handling, not admin registration.

Tip: Remember: admin.py is where you register models for the Django admin.

Question 6Medium

Which ModelAdmin option controls which fields appear as columns in the change list?

  1. fields
  2. list_filter
  3. display_columns
  4. list_display

Answer: D. list_display

Explanation

list_display takes field or method names.

Step-by-step solution

  1. List_display controls columns in change list.
  2. It uses field or method names.
  3. Option D is list_display.
  4. Final answer: D (list_display).

Why the other options are wrong

  • A. fields sets the form layout for editing, not the change list columns.
  • B. list_filter adds a sidebar of filters to the change list; it does not choose the columns.
  • C. display_columns is not a ModelAdmin option; the option is list_display.

Tip: Remember: list_display = columns in admin change list.

Question 7Medium

Which attribute lets you edit related child rows on the parent's admin page?

  1. children
  2. related_edit
  3. nested
  4. inlines (TabularInline or StackedInline)

Answer: D. inlines (TabularInline or StackedInline)

Explanation

Define an Inline class with model and add it to ModelAdmin.inlines.

Step-by-step solution

  1. Define inline.
  2. Attach.

Why the other options are wrong

  • A. children is not a valid option here; the correct choice is inlines (TabularInline or StackedInline).
  • B. related_edit is not a valid option here; the correct choice is inlines (TabularInline or StackedInline).
  • C. nested is not a valid option here; the correct choice is inlines (TabularInline or StackedInline).

Practise all 7 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Django topics · All topics