Skip to content

Instantly share code, notes, and snippets.

View dariushazimi's full-sized avatar

Dariush Azimi dariushazimi

View GitHub Profile
RELATIONSHIP_DOWNSTREAM = 1
RELATIONSHIP_UPSTREAM = 2
RELATIONSHIP_STATUSES = (
(RELATIONSHIP_DOWNSTREAM, 'DownStream'),
(RELATIONSHIP_UPSTREAM, 'UpStream'),
)
class Application(TimeStampModel):
@dariushazimi
dariushazimi / models.py
Last active April 22, 2016 04:27
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
# For Python 3.x
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people')
class Meta:
ordering = ['name']