This is the most common part of a Django technical interview.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # ====================================================================== # Q: Which models are used for the Django ORM live-coding exercises? # # This is the most common part of a Django technical interview. The interviewer # gives you models and asks for queries. Use these models for all the exercises: # ====================================================================== class Customer(models.Model): name = models.CharField(max_length=200) company = models.ForeignKey(Company, on_delete=models.PROTECT) class Product(models.Model): sku = models.CharField(max_length=50, unique=True) name = models.CharField(max_length=200) price = models.DecimalField(max_digits=10, decimal_places=2) stock = models.IntegerField(default=0) class Order(models.Model): customer = models.ForeignKey(Customer, on_delete=models.PROTECT, related_name='orders') status = models.CharField(max_length=20) # pending, paid, shipped, cancelled created_at = models.DateTimeField(auto_now_add=True) class OrderItem(models.Model): order = models.ForeignKey(Order, on_delete=models.CASCADE, related_name='items') product = models.ForeignKey(Product, on_delete=models.PROTECT) quantity = models.PositiveIntegerField() unit_price = models.DecimalField(max_digits=10, decimal_places=2) |