MCQs > IT & Programming > Django MCQs > Basic Django MCQs

Basic Django MCQ

1. Which is Fictional HTTP request method?

Answer

Correct Answer: PAUSE

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. 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

18. 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

19. 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

20. 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

21. 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

22. 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

23. 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

24. 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

25. 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

Answer

Correct Answer: Rest_framework.permissions.IsAuthenticated

Note: This Question is unanswered, help us to find answer for this one

26. What is a callable that takes a value and raises an error if the value fails?

Answer

Correct Answer: Validator

Note: This Question is unanswered, help us to find answer for this one

27. What decorator is used to require that a view accepts only the get and head methods?

Answer

Correct Answer: Require_safe()

Note: This Question is unanswered, help us to find answer for this one

28. Which infrastructure do you need: title=models.charfield(max_length=100, validators=[validate_spelling])

Answer

Correct Answer: A validators file containing a function called validate_spelling imported at the top of model

Note: This Question is unanswered, help us to find answer for this one

29. When to use the Django sites framework?

Answer

Correct Answer: If your single installation powers more than one site

Note: This Question is unanswered, help us to find answer for this one

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

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

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

Answer

Correct Answer: GET; POST

Note: This Question is unanswered, help us to find answer for this one

32. Which will show the currently installed version?

Answer

Correct Answer: Import django django.get_version()

Note: This Question is unanswered, help us to find answer for this one

33. 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

34. 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

35. 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

36. 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

37. 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

38. 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

39. 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

40. 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

41. 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

42. 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

43. 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

44. 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

45. 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

46. 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

47. 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

48. 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

49. 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

50. 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

51. 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

52. 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

53. 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

54. 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

55. 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

56. 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

57. In which programming language is Django written?

Answer

Correct Answer: Python

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Django.middleware.cache.AcceleratedCacheMiddleware

Note: This Question is unanswered, help us to find answer for this one

59. A circuit has an output that is determined by the present input as well as the previous output states. The circuit is known as _____.

Answer

Correct Answer: a sequential circuit

Note: This Question is unanswered, help us to find answer for this one

60. Which of the following is not a predefined log level in Django?

Answer

Correct Answer: FATAL

Note: This Question is unanswered, help us to find answer for this one

61.

Which of the following statements are true about the ImageField class?

Note: There may be more than one right answer.


Answer

Correct Answer:

It inherits all attributes and methods from the FileField class.


It validates that the uploaded object is a valid image.


It's default form widget is a ClearableFileInput.


Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

62.

Check all True facts about Django.

Note: There may be more than one right answer.


Answer

Correct Answer:

Written in Python



Web Application Framework



Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

63. What is the best way to extend the Django user model with extra custom fields in addition to the fields already provided?

Answer

Correct Answer: Subclass django.contrib.auth.models.AbstractUser and add the extra fields.

Note: This Question is unanswered, help us to find answer for this one

64. Which of the following statements is true about the django.template.RequestContext class?

Answer

Correct Answer: It takes an HttpRequest as its first argument.

Note: This Question is unanswered, help us to find answer for this one

65.

What is the default max_length value of a SlugField class in Django?

Answer

Correct Answer: 50

Note: This Question is unanswered, help us to find answer for this one

66.

Which of the following commands will make changes in the database tables schema?

Answer

Correct Answer: python manage.py migrate

Note: This Question is unanswered, help us to find answer for this one

67.

If an instance of a form is named ‘form’, which attribute of form instance holds all validated form data?

Answer

Correct Answer: form.cleaned_data

Note: This Question is unanswered, help us to find answer for this one

68.

Assume a, b, c, d and e are variables which hold some random integer from 1 to 10. Which of the following is NOT correct in django template?

Answer

Correct Answer: {% if a > b > c %}

Note: This Question is unanswered, help us to find answer for this one

69.

Which template command makes a custom template tag/filter available in template?

Answer

Correct Answer: {% load %}

Note: This Question is unanswered, help us to find answer for this one

70.

Which form method binds the data in the URL and is passed to the view?

Answer

Correct Answer: GET

Note: This Question is unanswered, help us to find answer for this one

71.

Which database is not supported by Django ORM?

Answer

Correct Answer: Mongodb

Note: This Question is unanswered, help us to find answer for this one

72.

Django is written in

Answer

Correct Answer: Python

Note: This Question is unanswered, help us to find answer for this one

73.

What is the correct way to randomly order a queryset?

Answer

Correct Answer: order_by('?')

Note: This Question is unanswered, help us to find answer for this one

74.

What is the correct way to Abstract Model class?

Answer

Correct Answer: Add abstract=True in Meta class

Note: This Question is unanswered, help us to find answer for this one

75.

Which of the following is true for model field names?

Answer

Correct Answer: Both of the above

Note: This Question is unanswered, help us to find answer for this one

76.

Which of the following gets called when a view raises an exception?

Answer

Correct Answer: process_exception()

Note: This Question is unanswered, help us to find answer for this one

77.

Which of the following is not a built-in Django template loader class?

Answer

Correct Answer: file.Loader

Note: This Question is unanswered, help us to find answer for this one

78.

Which is the correct way to start a new app inside a django project? [assume new app is called ‘myapp’]

Answer

Correct Answer: python manage.py startapp myapp

Note: This Question is unanswered, help us to find answer for this one

79.

Which of following statements is true to get a Queryset of all Entries which were published before 2006?

Answer

Correct Answer: Entry.objects.get(pub_date__year__in=2006)

Note: This Question is unanswered, help us to find answer for this one

80.

How would you check if a list my_list is empty or not in template ?

Answer

Correct Answer: Both 1 and 2

Note: This Question is unanswered, help us to find answer for this one

81.

Which types of users are allowed to login to the django administration site?

Answer

Correct Answer: Super users and staff users

Note: This Question is unanswered, help us to find answer for this one

82.

Which query includes a shirt with size 40?

Answer

Correct Answer: Both 2 and 3

Note: This Question is unanswered, help us to find answer for this one

83.

Which of the following are valid built-in signal provided by django? Check all that apply.

Answer

Correct Answer: request_started
m2m_changed

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

84.

What command line can be used to load data into Django?

Answer

Correct Answer: Django-admin.py loaddata

Note: This Question is unanswered, help us to find answer for this one

85.

Which of the following methods are allowed in django Listview? Check all that apply.

Note: There may be more than one right answer.

Answer

Correct Answer: get_context_data
get_queryset
get 

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

86.

What is the exception raised for this query Entry.objects.filter(blog_id=4)?

Answer

Correct Answer: TypeError

Note: This Question is unanswered, help us to find answer for this one

87.

What is the exception raised when the object is not found while performing the following query? Poll.objects.get(id=1)

Answer

Correct Answer: ObjectDoesNotExist

Note: This Question is unanswered, help us to find answer for this one

88.

Which of the following is NOT correct about Django Models?

Answer

Correct Answer: The name of the table is automatically derived from some model metadata and can not be overridden.

Note: This Question is unanswered, help us to find answer for this one

89.

Which of the following will not register a model "Test" to Django admin?

Answer

Correct Answer: admin(Test)

Note: This Question is unanswered, help us to find answer for this one

90.

Which of the following are built-in signal provided by Django?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

91.

Which of the following is a possible usage of middlewares in Django?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

92.

Which is the correct way to allow empty value in CharField?

Answer

Correct Answer: models.CharField(max_length=10, blank=True, null=True)

Note: This Question is unanswered, help us to find answer for this one

93.

What is TRUE about django-admin.py makemessages command?

Answer

Correct Answer: Pulls out all the strings marked for translation and makes a message file in the locale directory.

Note: This Question is unanswered, help us to find answer for this one

94.

Which of the following statements is true about the QuerySet select_related() method?

Answer

Correct Answer: Returns a QuerySet that will “follow” foreign-key relationships, selecting additional related-object data when it executes its query.

Note: This Question is unanswered, help us to find answer for this one

95.

Which of the following are determined by Django using field class types?

Answer

Correct Answer: The database column type
The default HTML widget to avail while rendering a form field

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

96.

Which of the following url patterns is used to register admin urls?

Answer

Correct Answer: url(r'^admin/', include(admin.site.urls))

Note: This Question is unanswered, help us to find answer for this one

97.

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

98.

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

99.

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

100.

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

101.

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

102.

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

103.

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

104.

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

105.

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

106.

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

107.

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

108.

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

109.

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

110.

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

111.

Which decorators are used to restrict authentication of users?

Note: There may be more than one right answer.

Answer

Correct Answer: @permission_required
@user_passes_test
@login_required 

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

112.

Which of the following is true about generators?

Answer

Correct Answer: Generators must contain a yield statement

Note: This Question is unanswered, help us to find answer for this one

113.

Which of the following is NOT used as a server for django in production?

Answer

Correct Answer: Ansible

Note: This Question is unanswered, help us to find answer for this one

114.

What is the full form of FBV and CBV?

Answer

Correct Answer: Function Based Views & Class Based Views

Note: This Question is unanswered, help us to find answer for this one

115.

Which of the following caching strategies are supported in Django? (check any that apply)

Note: There may be more than one right answer.

Answer

Correct Answer: File sytem caching
In-memory caching 

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

116.

Which of the following caching strategies can be implemented in Django?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

117.

Which of the following is the correct way to specify a translation string?

Answer

Correct Answer: Both of the above

Note: This Question is unanswered, help us to find answer for this one

118.

Which of the following features are supported by Django?

Answer

Correct Answer: All of the above 

Note: This Question is unanswered, help us to find answer for this one

119.

What is the exception raised when a duplicate value is used in unique field while inserting a record?

Answer

Correct Answer: IntegrityError

Note: This Question is unanswered, help us to find answer for this one

120.

Which is the correct way to allow empty value in Integer Field?

Answer

Correct Answer: models.IntegerField(blank=True, null=True)

Note: This Question is unanswered, help us to find answer for this one

121.

How can you set up static files in Django?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

122.

Django is a web __ in Python to develop a web application.

Answer

Correct Answer: Framework

Note: This Question is unanswered, help us to find answer for this one

123.

What does setting SESSION_COOKIE_SECURE = True do?

Answer

Correct Answer: Ensures cookie can be sent on HTTPS connection only

Note: This Question is unanswered, help us to find answer for this one

124.

Which of the following are correct ways to add a message?

Answer

Correct Answer: messages.add_message(request, messages.INFO, 'Hello world.')
messages.info(request, 'Hello world.')
messages.success(request, 'Hello world.') 

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

125.

Using a template tag you tried to load a templatetag as in {% load poll_extras %} and it failed, what could be the problem ?

Answer

Correct Answer: The app that contain the template tag is not in INSTALLED_APPS

Note: This Question is unanswered, help us to find answer for this one

126.

Which Django core function can be used to send an email?

Answer

Correct Answer: django.core.mail.send_mail

Note: This Question is unanswered, help us to find answer for this one

127.

What is the correct way to insert csrf token for forms in django template?

Answer

Correct Answer: form action="" method="post">{% csrf_token %}

Note: This Question is unanswered, help us to find answer for this one

128.

What is the exception raised if you are using POST against this function?

from django.views.decorators.http

import require_http_methods

@require_http_methods(["GET", "POST"]) 

def my_view(request):

    pass

Answer

Correct Answer: No exception will be raised

Note: This Question is unanswered, help us to find answer for this one

129.

What is the correct way to specify the fields to use in a Model Form?

Answer

Correct Answer: Either 1 or 2

Note: This Question is unanswered, help us to find answer for this one

130.

Which of the following is NOT used to represent ManyToManyField in django model form? Check all that apply.

Note: There may be more than one right answer.

Answer

Correct Answer: Charfield
ModelChoiceField

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

131.

How is the ManyToManyField represented in Django model form?

Answer

Correct Answer: ModelMultipleChoiceField

Note: This Question is unanswered, help us to find answer for this one

132. How would you create a ForeignKey from a model named Transaction, to a model named Product, with no reverse relation?

Answer

Correct Answer: class Transaction(models.Model): product = models.ForeignKey(Product, related_name='+')

Note: This Question is unanswered, help us to find answer for this one

133. 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

134. 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

135. Which of these can be used to retrieve a setting from the settings module, and provide a default if the setting is not defined?

Answer

Correct Answer: getattr(settings, "SETTING_NAME", default_value)

Note: This Question is unanswered, help us to find answer for this one

136. Which class is a model field representing a path to a server-based image file?

Answer

Correct Answer: django.db.models.fields.files.ImageField

Note: This Question is unanswered, help us to find answer for this one

137. 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

138. 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

139. 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

140. 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

141. Given an IntegerField named 'widgets' in the Django model 'User' , how do you calculate the average number of widgets per user?

Answer

Correct Answer: User.objects.all().aggregate( Avg( 'widgets' ) )

Note: This Question is unanswered, help us to find answer for this one

142. How can you define additional behavior and characteristics of a Django class?

Answer

Correct Answer: class Meta:

Note: This Question is unanswered, help us to find answer for this one

143. What is the command to start a new Django project called 'myproject'?

Answer

Correct Answer: django-admin.py startproject myproject

Note: This Question is unanswered, help us to find answer for this one

144. How to make django timezone-aware?

Answer

Correct Answer: In settings.py: USE_TZ=True

Note: This Question is unanswered, help us to find answer for this one

145. Assuming you've imported the proper Django model file, how do you add a 'User' model to the Django admin?

Answer

Correct Answer: admin.site.register( User )

Note: This Question is unanswered, help us to find answer for this one

146. How do you exclude a specific field from a ModelForm?

Answer

Correct Answer: Use the exclude parameter in the Meta class in your form

Note: This Question is unanswered, help us to find answer for this one

147. What preferred method do you add to a Django model to get a better string representation of the model in the Django admin?

Answer

Correct Answer: __unicode__

Note: This Question is unanswered, help us to find answer for this one

148. How do you define a 'name' field in a Django model with a maximum length of 255 characters?

Answer

Correct Answer: name = models.CharField(max_length=255)

Note: This Question is unanswered, help us to find answer for this one

149. What is the command to run Django's development server on port 8080 on IP address 12.34.56.78?

Answer

Correct Answer: manage.py runserver 12.34.56.78:8080

Note: This Question is unanswered, help us to find answer for this one

150. Django is written using what programming language?

Answer

Correct Answer: Python

Note: This Question is unanswered, help us to find answer for this one

search
Django Subjects