mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
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
This commit is contained in:
parent
dfa90aec1b
commit
f751d5b713
8 changed files with 140 additions and 3 deletions
30
tests/regressiontests/generic_inline_admin/models.py
Normal file
30
tests/regressiontests/generic_inline_admin/models.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue