An online learning platform allows users to choose courses taught by teachers. A teacher can teach one or more courses. The models below are used to handle the teacher and the courses they have:

from django.db import models

class Teacher(models.Model):
    name = models.CharField(max_length=200)
    contact = models.CharField(max_length=200)

    def __str__(self):

class Course(models.Model):
    teacher = models.ForeignKey(Teacher, on_delete=models.CASCADE)
    course_name = models.CharField(max_length=200)
    rating = models.IntegerField(default=0)

    def __str__(self):
        return self.course_name

Which options will be correct for the model methods and the database operations with the models?

(Select all acceptable answers.)

Printing a Teacher object such as print(Teacher(name="rob", contact="8888888888") will print only "rob".
Teacher.objects.filter(id=1) will throw an error as there is no field by the name of id in Teacher.
Deleting a Teacher object from the database using delete will automatically delete all rows for Course objects from the database that refer to the mentioned Teacher object.
Calling save on an object like Course(course_name="Mathematics", rating=5) will throw an error.
Course.objects.get(course_name="Physics") will return an empty QuerySet if no such records exist.

Django Model New Public


Would you like to see our other questions?

We have 1000+ premium hand-crafted questions for 160+ job skills and 20+ coding languages. We prefer questions with small samples of actual work over academic problems or brain teasers.

Visit our question library
Private Concierge

Send us an email with an explanation of your testing needs and a list of candidates. We will create an appropriate test, invite your candidates, review their results, and send you a detailed report.

Contact Private Concierge

Would you like to see our tests? The following tests contain Django related questions:
On the TestDome Blog

Screening Applicants: The Good, the Bad and the Ugly

Since we’re all biased and we use incorrect proxies, why not just outsource hiring to experts or recruitment agencies? After all, they’ve been screening people for many years, so they must know how to do it right?

Not really. I was surprised to discover that many experts disagree with each other. Everybody praises their pet method and criticizes the others. Many of these methods look legitimate, but are based on...

Dashboard Start Trial Sign In Home Tour Tests Questions Pricing