Skip to content

Instantly share code, notes, and snippets.

@mythmon
Created April 12, 2013 21:05
Show Gist options
  • Save mythmon/5375130 to your computer and use it in GitHub Desktop.
Save mythmon/5375130 to your computer and use it in GitHub Desktop.
class Document(ModelBase):
links_to_this = models.ManyToManyField('self', related_name='this_links_to',
symmetrical=False, through='DocumentLink')
class DocumentLink(ModelBase):
linked_from = models.ForeignKey(Document, related_name='documentlink_from_set')
linked_to = models.ForeignKey(Document, related_name='documentlink_to_set')
type = models.CharField(max_length=16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment