mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +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:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user