Django Linkedin Assessment Question Answers
Django is a free and open-source web framework written in Python. It is a powerful tool for building web applications quickly and efficiently.Django is designed to help developers take applications from concept to completion as quickly as possible. It is based on the principle of "batteries included," which means that it comes with many features and tools out-of-the-box, such as:
A powerful ORM (Object-Relational Mapper) for interacting with databases
A templating system for defining HTML templates and rendering them with context data
A built-in development server for testing applications locally
Support for many common web development tasks, such as user authentication, form validation, and routing
Django is often used for building database-driven websites, such as web applications, news sites, and social networks. It is fast, secure, and scalable, and it has a large and active community of users and developers.
Linkedin Django Assessment Question Answers
1. To expose an
existing model via an API endpoint, what do you need to implement?**
an HTTP request
a JSON object
a query
a serializer
2. How would you stop
Django from performing database table creation or deletion operations via
migrations for a particular model?
Run the migrate
command with --exclude=[model_name].
Move the model
definition from models.py into its own file.
Set managed=False inside the model.
Don't run the migrate
command.
3. What method can
you use to check if form data has changed when using a form instance?
has_changed()
its_changed()
has_updated()
None of This
4. What is WSGI?
a server
an interface specification
a Python module
a framework
5. Which is not a
Django filed type for holding integers?
SmallIntegerField
NegativeIntegerField
BigAutoField
PositiveIntegerField
6. Which will show
the currently installed version?
print
(django.version)
import django
django.getVersion()
import django django.get_version()
python -c django
--version
7. Which generic view
should be used for displaying the tittles of all Django Reinhardt's songs?
DetailView
TittleView
SongView
ListView
8. Which of these
variables are the settings for django.contib.staticfiles app?
STATIC_URL
STATIC_ROOT
STATICFILES_DIRS
All of the above
9. Which of the
following setting includes the parameter of main-URLs file?
static_url
dynamic_url
root_urlconfig
media_url
9. Which framework is
based on Django?
MVC
MVT
MVVC
MVVT
10. Which of these is
not a valid backend for caching in django?
django.core.cache.backends.sys.memory
django.core.cache.backends.db.DatabaseCache
django.core.cache.backends.locmem.LocMemCache
None of the above
11. What is the most
easiest, fastest, and most stable deployment choice in most cases with Django?
) FastCGI
mod_wsgi
SCGI
None of the above
12. What are the
caching strategies in Django?
File sytem caching
In-memory caching
Both A and B
None of the above
13. Which statement
is most accurate, regarding using the default SQLite database on your
local/development machine but
Postgres in
production
There's less chance of introducing bugs since SQLite
already works out the box
It's fine, you just
need to keep both instances synchronized
It's a bad idea and
could lead to issues down the road
It's the most
efficient way to build a project
14. Why might you
want to write a custom model Manager?
to perform database
queries
to set up a database
for testing
to modify the initial QuerySet that the Manager returns
to filter the results
that a database query returns
15. In Django, what
are used to customize the data that is sent to the templates?
models
views
forms
serializers
16. To complete the
conditional, what should this block of code end with?
% if sparles >= 50
%
Lots of sparkles!
% elif sparkles == 42
%
The answer to life, the universe, and
everything!
% endif %
Nothing else is
needed.
% end%
% else %
17. 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.
18. 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
19. What is the
correct way to begin a class called "Rainbow" in Python?
Rainbow {}
export Rainbow:
class Rainbow:
def Rainbow:
20. 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
21. You should use
the http method ___ to read data and ___ to update or create data
READ; WRITE
GET; POST
POST; GET
GET; PATCH
22. 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
23. When to use the
Django sites framework?
if your single installation powers more than one site
if you need to serve
static as well as dynamic content
if you want your app
have a fully qualified domain name
if you are expecting
more than 10.000 users
24. Which
infrastructure do you need:
title=models.charfield(max_length=100,
validators=[validate_spelling])
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
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
rest_framework.permissions.IsAdminUser
rest_framework.permissions.IsAuthenticated
rest_framework.permissions.IsAuthorized
rest_framework.permissions.IsRegistered
26. Which command
would you use to apply a migration?
makemigration
update_db
applymigration
migrate
27. 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
28. 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}.
29. 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.
30. Should you create
a custom user model for new projects?
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.
31. 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
32. What is the
meaning of {{name}} in Django Templates?
The name will be restored with values of Python variable.
It would be showed as
the name in HTML.
It will show the some
static value
None of the above
33. Which of the
following command are used to edition the SQL query of the model?
sqlmigrations
displaymigrations
migrations
makemigrations
34. What is the
Django command to view a database schema of an existing (or legacy) database?
manage.py inspect
manage.py legacydb
manage.py inspectdb
None of the above
35. Which of the
following password validators are not supported by default in Django?
MinimumLengthValidator
MaximumLengthValidator
NumericPasswordValidator
None of the above
36. Which Command
isused to create a project in Django?
Project
manage.py
_init_.py
All of the above
37. What is the
Django command to start a new app named ‘names’ in an existing project?
manage.py –newapp
names
manage.py newapp
names
manage.py –startapp
names
manage.py startapp names
38. Which of the
following is the Django shortcut method to more easily render an html response?
render
response_render
render_to_response
render_to_html
39. Which of the
following is a valid forloop attributes of Django Template System?
forloop.reverse
forloop.firstitem
forloop.counter0
forloop.lastitem
40. What is the
objective of __init__.py in project directories?
It can initialise any
null values.
It enables Python to
identify the folder as a package.
It can delete it
All the above
41. Which of the
following command is not a management command of staticfiles?
python manage.py makemigrations
python manage.py
findstatic
python manage.py
runstatic
python manage.py
collectstatic
42. 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
43. In which
programming language is Django written?
C++
Java
Python
Ruby
44. 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
45. If you left the
8080 off the command python manage.py runserver 8080 what port would Django use
as default?
8080
80
8000
It would fail to
start
46. Which statement
about Django apps is false?
A Django app is the top-level container for a web
application powered by Django.
Django apps are small
libraries designed to represent a single aspect of a project.
Each Django app
should do one thing, and one thing alone.
A Django project is
made up of many apps.
47. Which characters
are illegal in template variable names?
underscores.
uppercase letters.
punctuation marks .
numbers.
48. What is the
typical order of an HTTP request/response cycle in Django?
URL > view > template
form > model >
view
template > view
> model
URL > template
> view > model
49. Django's
class-based generic views provide which classes that implement common web
development tasks?
concrete
thread-safe
abstract
dynamic
50. Which skills do
you need to maintain a set of Django templates?
template syntax
HTML and template syntax
Python, HTML, and
template syntax
Python and template
syntax
51. Which class
allows you to automatically create a Serializer class with fields and
validators that correspond to your model's fields?
ModelSerializer
Model
DataSerializer
ModelToSerializer
52. Which command to
access the built-in admin tool for the first time?
django-admin setup
django-admin
runserver
python manage.py
createuser
python manage.py createsuperuser
53. Virtual
environments are for managing dependencies. Which granularity works best?
you should set up a new virtualenv for each Django project
They should not be
used
Use the same venv for
all your Django work
Use a new venv for
each Django app
54. You are building
a web application using a React front end and a Django back end. For what will
you need to provision?
an NGINX web server
a NoSQL database
a larger hard drive
CORS middleware
55. What is the
purpose of the init.py file?
to extend the set of
modules found in a package
to allow compiled
modules from different releases and different versions of Python to coexist
to initialize project
settings
to declare the directory contents as a Python module
56. Which best
practice is NOT relevant to migrations?
To make sure that your migrations are up to date, you
should run updatemigrations before running your tests.
You should back up
your production database before running a migration.
Your migration code
should be under source control.
If a project has a lot
of data, you should test against a staging copy before running the migration on
production.
57. 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
a string containing ^
and
an empty string
anywhere in the URLan empty string anywhere in the URL
58. 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.
59. What decorator is
used to require that a view accepts only the get and head methods?
require_safe()
require_put()
require_post()
require_get()
60. How would you
define the relation between a book and an author - book has only one author.
class Author
(models.model):
book=models.foreignkey(Book,on_delete=models.cascade)
class
Book(models.model):
name=models.charfield(max_length=100)
A
class Author (models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=models.foreignkey(Author,on_delete=models.cascade)
B
class Author
(models.model):
name=models.charfield(max_length=100)
class
Book(models.model):
author=models.foreignkey(Author)
C
class Author
(models.model):
name=models.charfield(max_length=100)
class
Book(models.model):
author=models.foreignkey(Author,on_delete=models.cascade)
D
class Author
(models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=Author.name
61. 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
62. What does an F()
object allow you when dealing with models?
perform db operations without fetching a model object
define db transaction
isolation levels
use aggregate
functions more easily
build reusable QuerySets
63. What executes
various Django commands such as running a webserver or creating an app?
migrate.py
wsgi.py
manage.py
runserver
64. What do Django
best practice suggest should be "fat"?
models
controllers
programmers
clients
65. What is the
result of this template code?
{{"live long and
prosper"|truncate:3}}
live long and ...
live long and
a compilation error
liv
66. When does this
code load data into memory?
1 sandwiches =
Sandwich.objects.filter(is_vegan=True)
2 for sandwich in
sandwiches:
3 print(sandwich.name + " - " +
sandwich.spice_level)
Line 1
It depends on how many results return by query.
It depends on cache.
line 2
67. How should the
code end?
{ percentage if spark
>= 50 percentage }
Lots of spark
{percentage elif
spark == 42 percentage}
{ percentage else
percentage}
{percentage endif percentage}
Nothing needed
{percentage end
percentage}
68. Which code block
will create a serializer?
from rest_framework
import serializers
from .models import Planet
A
class PlanetSerializer(serializers.ModelSerializer):
class Meta:
model=Planet
fields=('name','position', 'mass', 'rings')
B
from rest_framework
import serializers
from .models import
Planet
class
PlanetSerializer():
class Meta:
fields=('name','position',
'mass', 'rings')
model=Planet
C
from django.db import
serializers
from .models import
Planet
class
PlanetSerializer(serializers.ModelSerializer):
fields=('name','position',
'mass', 'rings')
model=Sandwich
D
from django.db import
serializers
from .models import
Planet
class
PlanetSerializer(serializers.ModelSerializer):
class Meta:
fields=('name')
model=Planet
69. Which is not a
valid closing template tag?
% endautoescape %
% endifempty %
% endcomment %
% endfilter %
70. When would you
need to use the reverse_lazy utility function instead of reverse?
when you want to
provide a reverse URL as a default value for a parameter in a function's
signature
when you want to
provide a reverse URL as the url attribute of a class-based generic view
when you want to
provide a URL to a decorator, such as the login_url argument for the
permission_required() decorator
all of the these answers
71. How would you
define the relationship between a star and a constellation in a Django model?
A
class Star(models.Model):
name = models.CharField(max_length=100)
class Constellation(models.Model):
stars = models.ManyToManyField(Star)
B
class
Star(models.Model):
constellation =
models.ForeignKey(Constellation, on_delete=models.CASCADE)
class
Constellation(models.Model):
stars =
models.ForeignKey(Star, on_delete=models.CASCADE)
C
class
Star(models.Model):
name =
models.CharField(max_length=100)
class
Constellation(models.Model):
stars =
models.OneToManyField(Star)
D
class
Star(models.Model):
constellation =
models.ManyToManyField(Constellation)
class
Constellation(models.Model):
name =
models.CharField(max_length=100)
72. 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()
73. Which is
Fictional HTTP request method?
POST
PUT
PAUSE
PATCH
74. Which helper
function is not provided as a part of django.shortcuts package?
render_to_request()
render()
redirect()
get_object_or_404()
75. Which is a
nonstandard place to store templates?
at the root level of a project
inside the
application
in the database
on Github
76. What is a
callable that takes a value and raises an error if the value fails?
validator
deodorizer
mediator
regular expression
77. A client wants
their site to be able to load "Rick & Morty" episodes by number
or by title—e.g., shows/3/3 or shows/picklerick. Which URL pattern do you
recommend?
A
url(r'shows/<int:season>/<int:episode>/',
views.episode_number),
url(r'shows/<slug:episode_name>/',
views.episode_name)
B
path('shows/<int:season>/<int:episode>/',
views.episode_number),
path('shows/<slug:episode_name>/',
views.episode_name)
C
path('shows/<int:season>/<int:episode>',
views.episode_number),
path('shows/<slug:episode_name>/',
views.episode_number)
D
url(r'^show/(?P<season>[0-9]+)/(?P<episode>[0-9]+)/$',
views.episode_number),
url(r'^show/(?P<episode_name>[\w-]+)/',
views.episode_name
78. How do you
determine at startup time if a piece of middleware should be used?
Raise MiddlewareNotUsed in the init function of your
middleware.
Implement the
not_used method in your middleware class.
List the middleware
beneath an entry of django.middleware.IgnoredMiddleware.
Write code to remove
the middleware from the settings in [app]/init.py.
79. 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
80. What is a
callable that takes a value and raises an error if the value fails to meet some
criteria?
mediator
validator
regular expression
deodorizer
81. 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.
82. Django supplies
sensible default values for settings. In which Python module can you find these
settings?
django.utils.default_settings.py
django.utils.global_settings.py
django.conf.default_settings.py
django.conf.global_settings.py
83. Which variable
name is best according to PEP 8 guidelines?
numFingers
number-of-Fingers
number_of_fingers
finger_num
84. Which is not part
of Django's design philosophy?
Loose Coupling
Less Code
Fast Development
Implicit over explicit
85. What python
module might be used to store the current state of a Django model in a file?
pickle
struct
marshal
serialize
86. To add a new app
to an existing Django project, you must edit the _ section of the _ file.
ALLOWED_HOSTS;
settings.py
APPS; manage.py
INSTALLED_APPS; settings.py
TEMPLATES; urls.py
87. 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.
88. 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?
Switch to using POST instead of GET as the request method.
Make sure the input
field in your form is also named "search_term".
Use MultiValueDict's
GET method instead of hitting the dictionary directly like this:
request.GET.get('search_term', '').
Check if the
search_term parameter is present in the request before attempting to access it.
89. Which is not a
third-party package commonly used for authentication?
django-guardian
django-rest-auth
authtoken
django-rest-framework-jwt
90. 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
91. Which function of
Django's Form class will render a form's fields as a series of tags?
show_fields()
as_p()
as_table()
fields()
92. What are the
features available in Django web framework?
Admin Interface (CRU
Templating
Form handling
All the above
93. Which below
option is the inheritance style in Django?
Abstract base classes
Multi-table
Inheritance
Proxy models
All the above
94. Which method is
used rather than a path() in urls.py to pass in regular expressions as routes?
url()
static()
path()
include()
95. What is the use
of per-site caching?
It is used to caching
of all the pictures on a website.
It is used to caching of the whole website.
It is used to caching
of all the static files.
It is used to Caching
of all the dynamic files.
What is Django? Django is a high-level Python web framework that enables rapid development of secure and maintainable websites. Built by experienced developers, Django takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel.
What are the advantages of Django?
Which is better Django or react?
Is Django only for websites?
Who uses Django framework?
django tutorial
django documentation
django name
django w3schools
django github
django vs flask
django download
django projects