Online Exam Quiz

questionQuestion  1 to 30

What is the default primary key field type in Django models?

  • IntegerField
  • CharField
  • AutoField
  • BigAutoField
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 use of the render function in Django views?

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

Which of the following is the default database for Django?

  • SQLite
  • MySQL
  • PostgreSQL
  • Oracle
Mark for review

How do you add a static file directory in Django?

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

How do you access the Django admin interface?

  • /admin
  • /dashboard
  • /control
  • /manage
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

Which command is used to create migrations based on model changes?

  • python manage.py migrate
  • python manage.py makemigrations
  • django-admin migrate
  • django-admin makemigrations
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 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

What is the file extension for Django template files?

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

How do you extend a base template in Django?

  • {% extend %}
  • {% base %}
  • {% extends %}
  • {% template %}
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

Which of the following is a valid Django template tag?

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

What is Django?

  • A Python framework
  • A JavaScript library
  • A CSS framework
  • A database
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 create a Django superuser?

  • python manage.py createsuperuser
  • python manage.py superuser
  • django-admin createsuperuser
  • django-admin superuser
Mark for review

What does the Django ORM stand for?

  • Object Relational Mapper
  • Object Resource Manager
  • Object Relational Management
  • Object Relationship Mapper
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

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

  • Define admin interface
  • Define database models
  • Define URL patterns
  • Define middleware
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

What is the purpose of the migrate command in Django?

  • Create new apps
  • Create database schema
  • Run unit tests
  • Create views
Mark for review

Which command is used to create a new Django app?

  • django createapp
  • django-admin startapp
  • django-admin createapp
  • django startapp
Mark for review

How do you start a new Django project?

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

How do you create a form in Django?

  • Create a Form class
  • Create a form function
  • Use the form template tag
  • Use the form model
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

What is the use of the context parameter in Django views?

  • Pass data to templates
  • Pass data to models
  • Pass data to forms
  • Pass data to admin interface
Mark for review

How do you filter query results in Django ORM?

  • Using filter() method
  • Using exclude() method
  • Using all() method
  • Using get() method
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 middleware component handles user authentication in Django?

  • AuthenticationMiddleware
  • SessionMiddleware
  • CommonMiddleware
  • CsrfViewMiddleware
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