django linkedin assessment answers
1. Why might you want to write a custom model Manager?
- 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
- to perform database queries
2. 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(); Form
- clean(); Field
- validate(); Model
- group (); Model
3. Which is not part of Dingo's design philosophy?
- less code
- loose coupling
- fast development
- implicit over explicit
4. How do you turn off Django's automatic HTML escaping for part of a web page?
- You don’t need to do anything-autoescaping is off by default.
- Wrap that section between (% autoescapeoff &} and {% endautoescapeoff %} tags.
- Wrap that section between (% autoescape off &) and (& endautoescape %} tags.
- Place that section between paragraph tags containing the autoescape=off switch.
5. Which statement is most accurate, regarding using the default SQLite database on your local/development machine but Postgres in production?
- It’s fine, you just need to keep both instances synchronized.
- It’s the most efficient way to build a project.
- There’s less chance of introducing bugs since SQLite already works out of the box.
- It’s a bad idea and could lead to issues down the road.
6. 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?
7. Which is not a third-party package commonly used for authentication?
- django-guardian
- authtoken
- django-rest-framework-jwt
- django-rest-auth
8. How would you define the relationship between a star and a constellation in a Django model?
9. Which statement about Diango apps is false?
- Each Django app should do one thing, and one thing alone.
- Django apps are small libraries designed to represent a single aspect of a project.
- A Django project is made up of many apps
- A Django app is the top-level container for a web application powered by Django.
10. 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.AcceleratedCacheMiddleware
- django.middleware.cache.FetchFromCacheMiddleware
12. 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
13. What method can you use to check if form data has been changed when using a Form instance?
- has_changed()
- changed_data ()
- is_modified()
- has_updated()
14. How would you stop Django from performing database table creation or deletion operations via migrations for a particular model?
- Set managed=False inside the model.
- Move the model definition from models.py into its own file.
- Run the migrate command with –exclude=[ model name ].
- Don’t run the migrate command.
15. What is the correct way to make a variable available to all of your templates?
- Use RequestContext.
- Add a dictionary to the template context.
- Set a session variable.
- Use a global variable