mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-28 04:24:00 +03:00
16 lines
391 B
Python
16 lines
391 B
Python
|
from django.db import models
|
||
|
|
||
|
|
||
|
class Item(models.Model):
|
||
|
name = models.CharField(max_length=10)
|
||
|
|
||
|
|
||
|
class ItemAmount(models.Model):
|
||
|
summary = models.ForeignKey('Summary', on_delete=models.CASCADE)
|
||
|
item = models.ForeignKey(Item, on_delete=models.CASCADE)
|
||
|
amount = models.IntegerField()
|
||
|
|
||
|
|
||
|
class Summary(models.Model):
|
||
|
items = models.ManyToManyField(Item, through=ItemAmount)
|