1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #12577. Reverted some changes from [12098] since [12206] made them unneccessary. Also, added a test for using generic inlines with unique_together. Thanks for the report, Raffaele Salmaso.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12268 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans
2010-01-21 01:40:21 +00:00
parent 63c5e6621a
commit 856a39e841
3 changed files with 51 additions and 16 deletions

View File

@@ -72,3 +72,24 @@ class MediaExcludeInline(generic.GenericTabularInline):
admin.site.register(EpisodeExclude, inlines=[MediaExcludeInline])
#
# Generic inline with unique_together
#
class PhoneNumber(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
phone_number = models.CharField(max_length=30)
class Meta:
unique_together = (('content_type', 'object_id', 'phone_number',),)
class Contact(models.Model):
name = models.CharField(max_length=50)
phone_numbers = generic.GenericRelation(PhoneNumber)
class PhoneNumberInline(generic.GenericTabularInline):
model = PhoneNumber
admin.site.register(Contact, inlines=[PhoneNumberInline])