linkedin-skill-assessments-quizzes

Django

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

Q2. In which programming language is Django written?

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.

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

url(r'shows/<int:season>/<int:episode>/', views.episode_number),
url(r'shows/<slug:episode_name>/', views.episode_name)
path('shows/<int:season>/<int:episode>/', views.episode_number),
path(r'shows/<slug:episode_name>/', views.episode_name)
path('shows/<int:season>/<int:episode>', views.episode_number),
path(r'shows/<slug:episode_name>/', views.episode_number)
url(r'^show/(?P<season>[0-9]+)/(?P<episode>[0-9]+)/$', views.episode_number),
url(r'^show/(?P<episode_name>[\w-]+)/', views.episode_name

Q5. How do you determine at startup time if a piece of middleware should be used?

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

Q7. Which step would NOT help you troubleshoot the error “django-admin: command not found”?

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

Q9. What is the correct way to begin a class called “Rainbow” in Python?

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

Q11. Which best practice is NOT relevant to migrations?

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

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

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

Q15. Which skills do you need to maintain a set of Django templates?

Q17. How would you define the relationship between a star and a constellation in a Django model?

class Star(models.Model):
name = models.CharField(max_length=100)
class Constellation(models.Model):
stars = models.ManyToManyField(Star)
class Star(models.Model):
constellation = models.ForeignKey(Constellation, on_delete=models.CASCADE)
class Constellation(models.Model):
stars = models.ForeignKey(Star, on_delete=models.CASCADE)
class Star(models.Model):
name = models.CharField(max_length=100)
class Constellation(models.Model):
stars = models.OneToManyField(Star)
class Star(models.Model):
constellation = models.ManyToManyField(Constellation)
class Constellation(models.Model):
name = models.CharField(max_length=100)

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

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

Q20. Should you create a custom user model for new projects?

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

Q22. Why are QuerySets considered “lazy”?

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

Q24. Which function of Django’s Form class will render a form’s fields as a series of <p> tags?

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

Q26. Django supplies sensible default values for settings. In which Python module can you find these settings?

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

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

Q29. What does an F() object allow you when dealing with models?

Q30. Which is not a Django filed type for integers?

Q31. Which will show the currently installed version?

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

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

Q34. When to use the Django sites framework?

Q35. Which infrastructure do you need:

title=models.charfield(max_length=100, validators=[validate_spelling])

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

Q37. 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)
class Author (models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=models.foreignkey(Author,on_delete=models.cascade)
class Author (models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=models.foreignkey(Author)
class Author (models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=models.foreignkey(Author,on_delete=models.cascade)
class Author (models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=Author.name

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

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

Q40. Which command would you use to apply a migration?

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

Q42. How should the code end?

{ percentage if spark >= 50 percentage }
Lots of spark
{percentage elif spark == 42 percentage}

Q43. Which code block will create a serializer?

from rest_framework import serializers
from .models import Planet
class PlanetSerializer(serializers.ModelSerializer):
class Meta:
model=Planet
fields=('name','position', 'mass', 'rings')
from rest_framework import serializers
from .models import Planet
class PlanetSerializer():
class Meta:
fields=('name','position', 'mass', 'rings')
model=Planet
from django.db import serializers
from .models import Planet
class PlanetSerializer(serializers.ModelSerializer):
fields=('name','position', 'mass', 'rings')
model=Sandwich
from django.db import serializers
from .models import Planet
class PlanetSerializer(serializers.ModelSerializer):
class Meta:
fields=('name')
model=Planet

Q44. Which class allows you to automatically create a Serializer class with fields and validators that correspond to your model’s fields?

Q45. Which command to access the built-in admin tool for the first time?

Q46. Virtual environments are for managing dependencies. Which granularity works best?

Q47. What executes various Django commands such as running a webserver or creating an app?

Q48. What do Django best practice suggest should be “fat”?

Q49. Which is not part of Django’s design philosophy?

Q50. What is the result of this template code?

...

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

Q52. You are building a web application using a React front end and a Django back end. For what will you need to provision?**

Q53. To expose an existing model via an API endpoint, what do you need to implement?**

Q54. How would you stop Django from performing database table creation or deletion operations via migrations for a particular model?**

Q55. what method can you use to check if form data has changed when using a form instance?

Q56. What is WSGI?

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

Q58. Which statement is most accurate, regarding using the default SQLite database on your local/development machine but Postgres in production

Q59. Why might you want to write a custom model Manager?

Q60. In Django, what are used to customize the data that is sent to the templates?

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

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

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

Q64. What is a callable that takes a value and raises an error if the value fails to meet some criteria?

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

Q66. What python module might be used to store the current state of a Django model in a file?

Q66. To add a new app to an existing Django project, you must edit the _ section of the _ file.

Q67. Which is not a third-party package commonly used for authentication?

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

Q69. Which is Fictional HTTP request method?

Q70. Which is not a Django field type for holding integers?