Note: This Question is unanswered, help us to find answer for this one
2. Which function in the django.urls package can help you avoid hardcoding URLS by generating a URL given the name of a view?
Answer
Correct Answer:
Reverse()
Note: This Question is unanswered, help us to find answer for this one
3. Which is not a third-party package commonly used for authentication?
Answer
Correct Answer:
Django-rest-framework-jwt
Note: This Question is unanswered, help us to find answer for this one
4. To add a new app to an existing Django project, you must edit the _ section of the _ file.
Answer
Correct Answer:
INSTALLED_APPS; settings.py
Note: This Question is unanswered, help us to find answer for this one
5. What python module might be used to store the current state of a Django model in a file?
Answer
Correct Answer:
Pickle
Note: This Question is unanswered, help us to find answer for this one
6. 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.
Answer
Correct Answer:
Request.FILES; FileField
Note: This Question is unanswered, help us to find answer for this one
7. What is a callable that takes a value and raises an error if the value fails to meet some criteria?
Answer
Correct Answer:
Validator
Note: This Question is unanswered, help us to find answer for this one
8. When should you employ the POST method over the GET method for submitting data from a form?
Answer
Correct Answer:
When the data in the form may be sensitive
Note: This Question is unanswered, help us to find answer for this one
9. In Django, what are used to customize the data that is sent to the templates?
Answer
Correct Answer:
Views
Note: This Question is unanswered, help us to find answer for this one
10. Why might you want to write a custom model Manager?
Answer
Correct Answer:
To modify the initial QuerySet that the Manager returns
Note: This Question is unanswered, help us to find answer for this one
11. Which statement is most accurate, regarding using the default SQLite database on your local/development machine but Postgres in production
Answer
Correct Answer:
There's less chance of introducing bugs since SQLite already works out the box
Note: This Question is unanswered, help us to find answer for this one
12. Which generic view should be used for displaying the tittles of all Django Reinhardt's songs?
Answer
Correct Answer:
ListView
Note: This Question is unanswered, help us to find answer for this one
13. What is WSGI?
Answer
Correct Answer:
A server
Note: This Question is unanswered, help us to find answer for this one
14. What method can you use to check if form data has changed when using a form instance?
Answer
Correct Answer:
Has_changed()
Note: This Question is unanswered, help us to find answer for this one
15. How would you stop Django from performing database table creation or deletion operations via migrations for a particular model?**
Answer
Correct Answer:
Set managed=False inside the model.
Note: This Question is unanswered, help us to find answer for this one
16. To expose an existing model via an API endpoint, what do you need to implement?**
Answer
Correct Answer:
A serializer
Note: This Question is unanswered, help us to find answer for this one
17. What is the result of this template code? {{"live long and prosper"|truncate:3}}
Answer
Correct Answer:
Live long and ...
Note: This Question is unanswered, help us to find answer for this one
18. Which is not part of Django's design philosophy?
Answer
Correct Answer:
Implicit over explicit
Note: This Question is unanswered, help us to find answer for this one
19. What do Django best practice suggest should be "fat"?
Answer
Correct Answer:
Models
Note: This Question is unanswered, help us to find answer for this one
20. What executes various Django commands such as running a webserver or creating an app?
Answer
Correct Answer:
Manage.py
Note: This Question is unanswered, help us to find answer for this one
21. Virtual environments are for managing dependencies. Which granularity works best?
Answer
Correct Answer:
You should set up a new virtualenv for each Django project
Note: This Question is unanswered, help us to find answer for this one
22. Which command to access the built-in admin tool for the first time?
Answer
Correct Answer:
Python manage.py createsuperuser
Note: This Question is unanswered, help us to find answer for this one
23. Which class allows you to automatically create a Serializer class with fields and validators that correspond to your model's fields?
Answer
Correct Answer:
ModelSerializer
Note: This Question is unanswered, help us to find answer for this one
24. Which type of class allows QuerySets and model instances to be converted to native Python data types for use in APIs?
Answer
Correct Answer:
Serializers
Note: This Question is unanswered, help us to find answer for this one
25. Which command would you use to apply a migration?
Answer
Correct Answer:
Migrate
Note: This Question is unanswered, help us to find answer for this one
26. To secure an API endpoint, making it accessible to registered users only, you can replace the rest_framework.permissions.allowAny value in the default_permissions section of your settings.py to
Note: This Question is unanswered, help us to find answer for this one
34. Which is not a Django filed type for integers?
Answer
Correct Answer:
NegativeIntegerField
Note: This Question is unanswered, help us to find answer for this one
35. What does an F() object allow you when dealing with models?
Answer
Correct Answer:
Perform db operations without fetching a model object
Note: This Question is unanswered, help us to find answer for this one
36. A project has accumulated 500 migrations. Which course of action would you pursue?
Answer
Correct Answer:
Use squashmigrations to reduce the number
Note: This Question is unanswered, help us to find answer for this one
37. Which variable name is best according to PEP 8 guidelines?
Answer
Correct Answer:
Number_of_fingers
Note: This Question is unanswered, help us to find answer for this one
38. Django supplies sensible default values for settings. In which Python module can you find these settings?
Answer
Correct Answer:
Django.conf.global_settings.py
Note: This Question is unanswered, help us to find answer for this one
39. You have found a bug in Django and you want to submit a patch. Which is the correct procedure?
Answer
Correct Answer:
All of these answers.
Note: This Question is unanswered, help us to find answer for this one
40. Which function of Django's Form class will render a form's fields as a series of tags?
Answer
Correct Answer:
As_p()
Note: This Question is unanswered, help us to find answer for this one
41. You receive a MultiValueDictKeyError when trying to access a request parameter with the following code: request.GET['search_term']. Which solution will NOT help you in this scenario?
Answer
Correct Answer:
Switch to using POST instead of GET as the request method.
Note: This Question is unanswered, help us to find answer for this one
42. Why are QuerySets considered "lazy"?
Answer
Correct Answer:
QuerySets do not create any database activity until they are evaluated.
Note: This Question is unanswered, help us to find answer for this one
43. 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?
Answer
Correct Answer:
Actions
Note: This Question is unanswered, help us to find answer for this one
44. Should you create a custom user model for new projects?
Answer
Correct Answer:
No. Django's built-in models.User class has been tried and tested—no point in reinventing the wheel.
Note: This Question is unanswered, help us to find answer for this one
45. What is the correct way to make a variable available to all of your templates?
Answer
Correct Answer:
Use RequestContext.
Note: This Question is unanswered, help us to find answer for this one
46. Which is NOT a valid step in configuring your Django 2.x instance to serve up static files such as images or CSS?
Answer
Correct Answer:
In your urls file, add a pattern that includes the name of your static directory.
Note: This Question is unanswered, help us to find answer for this one
47. Which skills do you need to maintain a set of Django templates?
Answer
Correct Answer:
HTML and template syntax
Note: This Question is unanswered, help us to find answer for this one
48. Django's class-based generic views provide which classes that implement common web development tasks?
Answer
Correct Answer:
Abstract
Note: This Question is unanswered, help us to find answer for this one
49. What is the typical order of an HTTP request/response cycle in Django?
Answer
Correct Answer:
URL > view > template
Note: This Question is unanswered, help us to find answer for this one
50. What will this URL pattern match? url(r'^$', views.hello)
Answer
Correct Answer:
An empty string at the server root
Note: This Question is unanswered, help us to find answer for this one
51. Which best practice is NOT relevant to migrations?
Answer
Correct Answer:
To make sure that your migrations are up to date, you should run updatemigrations before running your tests.
Note: This Question is unanswered, help us to find answer for this one
52. 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?
Answer
Correct Answer:
Pip install -r requirements.txt
Note: This Question is unanswered, help us to find answer for this one
53. What is the correct way to begin a class called "Rainbow" in Python?
Answer
Correct Answer:
Class Rainbow:
Note: This Question is unanswered, help us to find answer for this one
54. Every time a user is saved, their quiz_score needs to be recalculated. Where might be an ideal place to add this logic?
Answer
Correct Answer:
Model
Note: This Question is unanswered, help us to find answer for this one
55. Which step would NOT help you troubleshoot the error "django-admin: command not found"?
Answer
Correct Answer:
Make sure that you have created a Django project.
Note: This Question is unanswered, help us to find answer for this one
56. How do you turn off Django’s automatic HTML escaping for part of a web page?
Answer
Correct Answer:
You don't need to do anything—autoescaping is off by default.
Note: This Question is unanswered, help us to find answer for this one
57. How do you determine at startup time if a piece of middleware should be used?
Answer
Correct Answer:
Raise MiddlewareNotUsed in the init function of your middleware.
Note: This Question is unanswered, help us to find answer for this one
58. 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.
Answer
Correct Answer:
Clean(); Field
Note: This Question is unanswered, help us to find answer for this one
59. In which programming language is Django written?
Answer
Correct Answer:
Python
Note: This Question is unanswered, help us to find answer for this one
60. To cache your entire site for an application in Django, you add all except which of these settings?
Note: This Question is unanswered, help us to find answer for this one
102.
What is true about the management command collectstatic?
Answer
Correct Answer:
Takes all of the static files of your project and puts them in the folder specified in STATIC_ROOT so they can be served in production.
Note: This Question is unanswered, help us to find answer for this one
103.
What is the name of the command line tool that Django provides for managing a newly created project and its applications?
Answer
Correct Answer:
manage.py
Note: This Question is unanswered, help us to find answer for this one
104.
Which of the following is not true about testing?
Answer
Correct Answer:
The command used to run all unit tests is ./manage.py test --all
Note: This Question is unanswered, help us to find answer for this one
105.
Which command runs all test in a django project?
Answer
Correct Answer:
python manage.py test
Note: This Question is unanswered, help us to find answer for this one
106.
What kind of relation is defined between models A and B by invoking ForeignKey(A) in the class definition for model B?
Answer
Correct Answer:
Many to one: Many instances of B can have one instance of A
Note: This Question is unanswered, help us to find answer for this one
107.
Which of the following is not True?
Answer
Correct Answer:
Django does not support Unicode data everywhere.
Note: This Question is unanswered, help us to find answer for this one
108.
Which of the following is not a layer in Django?
Answer
Correct Answer:
None of the above
Note: This Question is unanswered, help us to find answer for this one
109.
Which of the following classes uses an HTTP 304 status code?
Answer
Correct Answer:
HttpResponseNotModified
Note: This Question is unanswered, help us to find answer for this one
110.
Which template tag is used to add another template to the current one?
Answer
Correct Answer:
include
Note: This Question is unanswered, help us to find answer for this one
111.
How would you iterate through a list called my_list in template ?
Answer
Correct Answer:
{% for x in my_list %} {% endfor %}
Note: This Question is unanswered, help us to find answer for this one
112.
Which data structure is used to pass context values from views to template?
Answer
Correct Answer:
Dictionary
Note: This Question is unanswered, help us to find answer for this one
113.
Which query gives the count of vehicles that are private?
Answer
Correct Answer:
Both 1 and 3
Note: This Question is unanswered, help us to find answer for this one
114.
Which attribute is used to order the objects in django admin?
Answer
Correct Answer:
ordering
Note: This Question is unanswered, help us to find answer for this one
115.
Which of the following methods is not used in django ListView?
Answer
Correct Answer:
get_object
Note: This Question is unanswered, help us to find answer for this one
116.
Which is the correct way to create a superuser from command line?
Answer
Correct Answer:
python manage.py createsuperuser
Note: This Question is unanswered, help us to find answer for this one
117.
Which decorators are used to restrict authentication of users?
Note: This Question is unanswered, help us to find answer for this one
145. A model's "full_clean()" method is called automatically when you call your model's "save()" method.
Answer
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
146. How to set a default order by in your Django model ? YourModel.objects.all() will be ordered by default without calling order_by() method
Answer
Correct Answer:
Using META ordering attribute
Note: This Question is unanswered, help us to find answer for this one
147. Which type of custom template tag returns a string?
Answer
Correct Answer:
simple_tag
Note: This Question is unanswered, help us to find answer for this one
148. In your django template, if you need to get the content of the block from the django parent template, what do you need to add? {% block my_block %} ___________ {% endblock %}
Answer
Correct Answer:
{{ block.super }}
Note: This Question is unanswered, help us to find answer for this one
149. The django.contrib.contenttypes application provides
Answer
Correct Answer:
a generic interface for working with models
Note: This Question is unanswered, help us to find answer for this one
150. The Benevolent Dictators for Life of the Django Project are:
Answer
Correct Answer:
Jacob Kaplan-Moss and Adrian Holovaty
Note: This Question is unanswered, help us to find answer for this one
151. Which of these can be used to retrieve a setting from the settings module, and provide a default if the setting is not defined?
Note: This Question is unanswered, help us to find answer for this one
153. How do you create a recursive relationship in a model class named 'Company' in Django?
Answer
Correct Answer:
models.ForeignKey('self')
Note: This Question is unanswered, help us to find answer for this one
154. You have a Form defined with "password" and "confirm_password" fields. In what method of the "form" object would you validate that the values supplied in these fields match?
Answer
Correct Answer:
form.clean
Note: This Question is unanswered, help us to find answer for this one
155. In settings.py, when DEBUG is set to ________, Django will email unhandled exceptional conditions.
Answer
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
156. What is the command used to print the CREATE TABLE SQL statements for the given app name?
Answer
Correct Answer:
./manage.py sql myapp
Note: This Question is unanswered, help us to find answer for this one
157. What command do you use to alter the fields Django displays for a given model in the Django admin ListView?
Answer
Correct Answer:
list_display
Note: This Question is unanswered, help us to find answer for this one
158. When customizing validation in a Form subclass named MyForm, how do you add an error message that is displayed as a form-wide error?
Answer
Correct Answer:
Raise ValidationError in MyForm.clean()
Note: This Question is unanswered, help us to find answer for this one
159. You can handle multiple Django forms with what keyword argument when creating forms?
Answer
Correct Answer:
prefix
Note: This Question is unanswered, help us to find answer for this one
160. How to create a DateTimeField named created and filled in only on the creation with the current time?
Answer
Correct Answer:
created = models.DateTimeField(auto_now_add=True)
Note: This Question is unanswered, help us to find answer for this one
161. What is the Django command to retrieve the first 10 'User' records from your database sorted by name descending?
Note: This Question is unanswered, help us to find answer for this one
162. You have created a Form class and wish to provide custom logic for validating the input in the "foo" field. What would you name your custom validation method?
Answer
Correct Answer:
clean_foo
Note: This Question is unanswered, help us to find answer for this one
163. Given a form with field foo, what should the validation method for this field be called?
Answer
Correct Answer:
clean_foo
Note: This Question is unanswered, help us to find answer for this one
164. What command compile Django's translation files?
Answer
Correct Answer:
./manage.py compilemessages
Note: This Question is unanswered, help us to find answer for this one
165. Given a model named 'User' that contains a field named 'email', how do you perform a case-insensitive exact match for the email 'fred@aol.com'?
Note: This Question is unanswered, help us to find answer for this one
169. Given the Python data: mydata = [ [ 0, 'Fred' ], [ 1, 'Wilma' ] ] How do you access the data in a Django template?
Answer
Correct Answer:
{% for d in mydata %} <p><a href="/users/{{ d.0 }}/">{{ d.1 }}</a></p> {% endfor %}
Note: This Question is unanswered, help us to find answer for this one
170. What is the purpose of the STATIC_ROOT setting?
Answer
Correct Answer:
Defines the location where all static files will be copied by the 'collectstatic' management command, to be served by the production webserver.
Note: This Question is unanswered, help us to find answer for this one
171. What is the correct way to include django's admin urls? from django.contrib import admin') from django.conf.urls import patterns, include, url urlpatterns = patterns('', ______________________ )