Django - Skill Assignment Quiz

Q1. To cache your entire site for an application in Django, you add all except which of these settings?

  •  django.middleware.common.CommonMiddleware
  •  django.middleware.cache.UpdateCacheMiddleware
  •  django.middleware.cache.FetchFromCacheMiddleware
  •  django.middleware.cache.AcceleratedCacheMiddleware

Q2. In which programming language is Django written?

  •  C++
  •  Java
  •  Python
  •  Ruby

Q3. To automatically provide a value for a field, or to do validation that requires access to more than a single field, you should override the ___ method in the ___ class.

  •  validate(); Model
  •  group(); Model
  •  validate(); Form
  •  clean(); Field

Q4. How do you turn off Django’s automatic HTML escaping for part of a web page?

  •  Place that section between paragraph tags containing the autoescape=off switch.
  •  Wrap that section between { percentage mark autoescape off percentage mark} and {percentage mark endautoescape percentage mark} tags.
  •  Wrap that section between {percentage mark autoescapeoff percentage mark} and {percentage mark endautoescapeoff percentage mark} tags.
  •  You don't need to do anything—autoescaping is off by default.

Q5. Which step would NOT help you troubleshoot the error "django-admin: command not found"?

  •  Check that the bin folder inside your Django directory is on your system path.
  •  Make sure you have activated the virtual environment you have set up containing Django.
  •  Check that you have installed Django.
  •  Make sure that you have created a Django project.

Q6. Every time a user is saved, their quiz_score needs to be recalculated. Where might be an ideal place to add this logic?

  •  template
  •  model
  •  database
  •  view

Q7. What is the correct way to begin a class called "Rainbow" in Python?

  •  Rainbow {}
  •  export Rainbow:
  •  class Rainbow:
  •  def Rainbow:

Q8. You have inherited a Django project and need to get it running locally. It comes with a requirements.txt file containing all its dependencies. Which command should you use?

  •  django-admin startproject requirements.txt
  •  python install -r requirements.txt
  •  pip install -r requirements.txt
  •  pip install Django

Q9. What will this URL pattern match? url(r'^$', views.hello)

  •  a string beginning with the letter Ra string beginning with the letter R
  •  an empty string at the server root
  •  an empty string anywhere in the URLan empty string anywhere in the URL

Q10. What is the typical order of an HTTP request/response cycle in Django?

  •  a string beginning with the letter Ra string beginning with the letter R
  •  an empty string at the server root
  •  an empty string anywhere in the URLan empty string anywhere in the URL

Q11. Django's class-based generic views provide which classes that implement common web development tasks?

  •  template syntax
  •  HTML and template syntax
  •  Python, HTML, and template syntax
  •  Python and template syntax

Q12. Which is NOT a valid step in configuring your Django 2.x instance to serve up static files such as images or CSS?

  •  In your urls file, add a pattern that includes the name of your static directory.
  •  Create a directory named static inside your app directory.
  •  Create a directory named after the app under the static directory, and place static files inside.
  •  Use the template tag {percentage mark load static percentage mark}.

Q13. What is the correct way to make a variable available to all of your templates?

  •  Set a session variable.
  •  Use a global variable.
  •  Add a dictionary to the template context.
  •  Use RequestContext.

Q14. What is the correct way to make a variable available to all of your templates?

  •  No. Using a custom user model could break the admin interface and some third-party apps.
  •  Yes. It is easier to make changes once it goes into production.
  •  No. Django's built-in models.User class has been tried and tested—no point in reinventing the wheel.
  •  Yes, as there is no other option.

Q15. You want to create a page that allows editing of two classes connected by a foreign key (e.g., a question and answer that reside in separate tables). What Django feature can you use?

  •  actions
  •  admin
  •  mezcal
  •  inlines

Q16. Why are QuerySets considered "lazy"?

  •  The results of a QuerySet are not ordered.
  •  QuerySets do not create any database activity until they are evaluated.
  •  QuerySets do not load objects into memory until they are needed.
  •  Using QuerySets, you cannot execute more complex queries.

Q17. You have found a bug in Django and you want to submit a patch. Which is the correct procedure?

  •  Fork the Django repository GitHub.
  •  Submit a pull request.
  •  all of these answers.
  •  Run Django's test suite.

Q18. You have found a bug in Django and you want to submit a patch. Which is the correct procedure?

  •  django.utils.default_settings.py
  •  django.utils.global_settings.py
  •  django.conf.default_settings.py
  •  django.conf.global_settings.py

Q19. Which variable name is best according to PEP 8 guidelines?

  •  numFingers
  •  number-of-Fingers
  •  number_of_fingers
  •  finger_num

Q20. A project has accumulated 500 migrations. Which course of action would you pursue?

  •  Manually merge your migration files to reduce the number
  •  Don't worry about the number
  •  Try to minimize the number of migrations
  •  Use squashmigrations to reduce the number

Q21. Which is not a Django filed type for holding integers?

  •  SmallIntegerField
  •  NegativeIntegerField
  •  BigAutoField
  •  PositiveIntegerField

Q22. You should use the http method ___ to read data and ___ to update or create data

  •  READ; WRITE
  •  GET; POST
  •  POST; GET
  •  GET; PATCH

Q23. When should you employ the POST method over GET for submitting data?

  •  when efficiency is important
  •  when you want the data to be cached
  •  when you want to use your browser to help with debugging
  •  when the data in the form may be sensitive

Q24. When should you employ the POST method over GET for submitting data?

  •  inizialized array called validators
  •  a validators file containing a function called validate_spelling imported at the top of model
  •  a validators file containing a function called validate imported at the top of model
  •  spelling package imported at the top of model

Q25. Which type of class allows QuerySets and model instances to be converted to native Python data types for use in APIs?

  •  objectwriters
  •  serializers
  •  picklers
  •  viewsets

Q26. What do Django best practice suggest should be "fat"?

  •  models
  •  controllers
  •  programmers
  •  clients

Q27. Which generic view should be used for displaying the tittles of all Django Reinhardt's songs?

  •  DetailView
  •  TittleView
  •  SongView
  •  ListView

Q28. When should you employ the POST method over the GET method for submitting data from a form?

  •  when the data in the form may be sensitive
  •  when you want the data to be cached
  •  when you want to use your browser to help with debugging
  •  when efficiency is important

Q29. You are uploading a file to Django from a form and you want to save the received file as a field on a model object. You can simply assign the file object from**_to a field of type__**in the model.

  •  request.META; FileField
  •  request.FILES; BLOBField
  •  request.FILES; FileField
  •  request.META.Files; CLOBField

Q30. Which function in the django.urls package can help you avoid hardcoding URLS by generating a URL given the name of a view?

  •  get_script_prefix()
  •  redirect()
  •  reverse()
  •  resolve()

Q31. Which helper function is not provided as a part of django.shortcuts package? ref-

  •  render_to_request()
  •  render()
  •  redirect()
  •  get_object_or_404()

Q32. What python package can be used to edit numbers into more readable form like "1200000" to "1.2 million"?

  •  black
  •  puffer
  •  pitch
  •  humanize

READY TO GET STARTED?

Are you ready

Let’s Make Something Amazing Together

Need help? Contact our experts
Tell us about your project