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?

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”?