mirror of
https://github.com/django/django.git
synced 2024-11-19 16:04:13 +00:00
f751d5b713
This case pops up with generic foreign key inlines after [9297]. Added tests to handle future regressions with generic foreign key inlines in the admin. Thanks markus and danielr for patches. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9412 bcc190cf-cafb-0310-a4f2-bffc1f526a37
31 lines
788 B
Python
31 lines
788 B
Python
from django.db import models
|
|
from django.contrib import admin
|
|
from django.contrib.contenttypes import generic
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
class Episode(models.Model):
|
|
name = models.CharField(max_length=100)
|
|
|
|
class Media(models.Model):
|
|
"""
|
|
Media that can associated to any object.
|
|
"""
|
|
content_type = models.ForeignKey(ContentType)
|
|
object_id = models.PositiveIntegerField()
|
|
content_object = generic.GenericForeignKey()
|
|
url = models.URLField(verify_exists=False)
|
|
|
|
def __unicode__(self):
|
|
return self.url
|
|
|
|
class MediaInline(generic.GenericTabularInline):
|
|
model = Media
|
|
extra = 1
|
|
|
|
class EpisodeAdmin(admin.ModelAdmin):
|
|
inlines = [
|
|
MediaInline,
|
|
]
|
|
|
|
admin.site.register(Episode, EpisodeAdmin)
|