PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/tests/modeltests/m2m_and_m2o/models.py

https://code.google.com/p/mango-py/
Python | 21 lines | 11 code | 5 blank | 5 comment | 0 complexity | edf384439b1b51cf1fe434cb2f1fe523 MD5 | raw file
 1"""
 229. Many-to-many and many-to-one relationships to the same table
 3
 4Make sure to set ``related_name`` if you use relationships to the same table.
 5"""
 6
 7from django.db import models
 8
 9class User(models.Model):
10    username = models.CharField(max_length=20)
11
12class Issue(models.Model):
13    num = models.IntegerField()
14    cc = models.ManyToManyField(User, blank=True, related_name='test_issue_cc')
15    client = models.ForeignKey(User, related_name='test_issue_client')
16
17    def __unicode__(self):
18        return unicode(self.num)
19
20    class Meta:
21        ordering = ('num',)