1
0
mirror of https://github.com/django/django.git synced 2024-12-25 10:35:48 +00:00
django/tests/regressiontests/generic_inline_admin/models.py
Brian Rosner f751d5b713 Fixed #9498 -- Handle a formset correctly when the foreign key is not available (for now).
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
2008-11-13 19:03:44 +00:00

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)