2006-05-02 01:31:56 +00:00
|
|
|
"""
|
2007-03-23 20:17:04 +00:00
|
|
|
29. Many-to-many and many-to-one relationships to the same table
|
2006-05-02 01:31:56 +00:00
|
|
|
|
2006-05-31 19:23:07 +00:00
|
|
|
Make sure to set ``related_name`` if you use relationships to the same table.
|
2006-05-02 01:31:56 +00:00
|
|
|
"""
|
2012-06-07 16:08:47 +00:00
|
|
|
from __future__ import unicode_literals
|
2006-05-02 01:31:56 +00:00
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
|
2011-10-13 18:04:12 +00:00
|
|
|
|
2006-05-02 01:31:56 +00:00
|
|
|
class User(models.Model):
|
2007-08-05 05:14:46 +00:00
|
|
|
username = models.CharField(max_length=20)
|
2006-05-02 01:31:56 +00:00
|
|
|
|
|
|
|
class Issue(models.Model):
|
|
|
|
num = models.IntegerField()
|
|
|
|
cc = models.ManyToManyField(User, blank=True, related_name='test_issue_cc')
|
|
|
|
client = models.ForeignKey(User, related_name='test_issue_client')
|
2006-05-31 19:23:07 +00:00
|
|
|
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 12:11:04 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return unicode(self.num)
|
2006-05-31 19:10:43 +00:00
|
|
|
|
2006-05-02 01:31:56 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ('num',)
|
2011-08-24 03:51:33 +00:00
|
|
|
|
2011-10-13 18:04:12 +00:00
|
|
|
class UnicodeReferenceModel(models.Model):
|
2012-06-07 16:08:47 +00:00
|
|
|
others = models.ManyToManyField("UnicodeReferenceModel")
|
2011-08-24 03:51:33 +00:00
|
|
|
|