Online Exam Quiz

questionQuestion  1 to 30

What is the file extension for Django template files?

  • .html
  • .py
  • .dt
  • .tpl
Mark for review

How do you specify a one-to-one relationship in Django models?

  • models.OneToOneField
  • models.ForeignKey
  • models.ManyToManyField
  • models.OneToManyField
Mark for review

Which of the following is a valid Django template tag?

  • {% url %}
  • <% url %>
  • {{ url }}
  • [[ url ]]
Mark for review

How do you access the Django admin interface?

  • /admin
  • /dashboard
  • /control
  • /manage
Mark for review

What is the purpose of Django's middleware?

  • Process requests and responses
  • Define view functions
  • Define database models
  • Define URL patterns
Mark for review

How do you extend a base template in Django?

  • {% extend %}
  • {% base %}
  • {% extends %}
  • {% template %}
Mark for review

What is the use of the get_object_or_404 function in Django views?

  • Query the database
  • Retrieve an object or return 404
  • Handle form submissions
  • Render a template
Mark for review

What is the purpose of Django's urls.py file in an app directory?

  • Define URL patterns specific to the app
  • Define view functions
  • Define database models
  • Define admin configurations
Mark for review

How do you serve media files in Django during development?

  • Add MEDIA_URL and MEDIA_ROOT in settings.py
  • Add STATIC_URL in settings.py
  • Add TEMPLATES in settings.py
  • Add INSTALLED_APPS in settings.py
Mark for review

How do you add a new middleware component in Django?

  • Add to MIDDLEWARE in settings.py
  • Add to INSTALLED_APPS in settings.py
  • Add to TEMPLATES in settings.py
  • Add to STATICFILES_DIRS in settings.py
Mark for review

What does the __str__ method do in Django models?

  • Define the string representation of the model
  • Define the model's fields
  • Define the model's methods
  • Define the model's admin interface
Mark for review

What is the use of the render function in Django views?

  • Send an email
  • Render a template
  • Query the database
  • Handle user sessions
Mark for review

What is the purpose of the Django Debug Toolbar?

  • Debug Django applications
  • Test Django applications
  • Profile Django applications
  • Secure Django applications
Mark for review

What file in a Django app directory contains the app's configuration?

  • views.py
  • models.py
  • admin.py
  • apps.py
Mark for review

What is the purpose of the reverse function in Django?

  • Reverse a string
  • Reverse a list
  • Get the URL for a given view
  • Reverse a queryset
Mark for review

What is the purpose of Django's admin.site.register function?

  • Register models with the admin site
  • Register views with the admin site
  • Register URLs with the admin site
  • Register templates with the admin site
Mark for review

What is the purpose of Django's models.py file?

  • Define view functions
  • Define database models
  • Define URL patterns
  • Define admin configurations
Mark for review

What is the purpose of Django's settings.py file?

  • Configure the database
  • Configure the project
  • Configure the URLs
  • Configure the models
Mark for review

What is the purpose of the urls.py file in a Django project?

  • Define database models
  • Define view functions
  • Define URL patterns
  • Define middleware
Mark for review

How do you run a Django development server?

  • django-admin runserver
  • django runserver
  • python manage.py runserver
  • python runserver
Mark for review

How do you define a foreign key relationship in Django models?

  • models.ForeignKey
  • models.OneToOneField
  • models.ManyToManyField
  • models.ForeignKeyField
Mark for review

How do you define a URL pattern in Django?

  • path('url/', view_name)
  • url('url/', view_name)
  • urlpatterns = [url('url/', view_name)]
  • urlpatterns = [path('url/', view_name)]
Mark for review

What is the purpose of Django's views.py file?

  • Define view functions
  • Define database models
  • Define URL patterns
  • Define admin configurations
Mark for review

What is the purpose of Django's forms.py file?

  • Define forms
  • Define models
  • Define URL patterns
  • Define admin configurations
Mark for review

What is Django?

  • A Python framework
  • A JavaScript library
  • A CSS framework
  • A database
Mark for review

What does the login_required decorator do in Django?

  • Restrict access to logged-in users
  • Restrict access to admin users
  • Restrict access to superusers
  • Restrict access to anonymous users
Mark for review

How do you perform a raw SQL query in Django?

  • MyModel.objects.raw('SELECT * FROM mytable')
  • MyModel.objects.query('SELECT * FROM mytable')
  • MyModel.objects.execute('SELECT * FROM mytable')
  • MyModel.objects.sql('SELECT * FROM mytable')
Mark for review

How do you include a URLconf from another app in urls.py?

  • include('app_name.urls')
  • include app_name.urls
  • include[app_name.urls]
  • include.app_name.urls
Mark for review

Which of the following is not a valid Django model field type?

  • CharField
  • EmailField
  • TextField
  • DictField
Mark for review

How do you start a new Django project?

  • django startproject
  • django-admin startproject
  • django-admin createproject
  • django createproject
Mark for review

blinkerOnline

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • Answered
  • Not Answered
  • Marked for Review