Skip to content

Instantly share code, notes, and snippets.

@aynik
Last active November 10, 2020 14:31
Show Gist options
  • Save aynik/5cece90ce59ac5e9c09b3e22d63cbc30 to your computer and use it in GitHub Desktop.
Save aynik/5cece90ce59ac5e9c09b3e22d63cbc30 to your computer and use it in GitHub Desktop.
from django.db import models
class Item(models.Model):
title = models.CharField(max_length=128)
class GroupItems(models.Model):
group = models.ForeignKey(Group)
item = models.ForeignKey(Item)
class Group(models.Model):
items = models.ManyToManyField(Item, through='GroupItems')
seleted_item = models.ForeignKey(GroupItems)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment