mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
[1.0.X] Fixed #9863. A ForeignKey with editable=False to the parent in an inline no longer raises an exception. Thanks to keithb for the test case and Alex Gaynor for the patch. Backport of r10239 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10287 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -177,6 +177,20 @@ class PersonaAdmin(admin.ModelAdmin):
|
||||
BarAccountAdmin
|
||||
)
|
||||
|
||||
class Parent(models.Model):
|
||||
name = models.CharField(max_length=128)
|
||||
|
||||
class Child(models.Model):
|
||||
parent = models.ForeignKey(Parent, editable=False)
|
||||
name = models.CharField(max_length=30, blank=True)
|
||||
|
||||
class ChildInline(admin.StackedInline):
|
||||
model = Child
|
||||
|
||||
class ParentAdmin(admin.ModelAdmin):
|
||||
model = Parent
|
||||
inlines = [ChildInline]
|
||||
|
||||
admin.site.register(Article, ArticleAdmin)
|
||||
admin.site.register(CustomArticle, CustomArticleAdmin)
|
||||
admin.site.register(Section, inlines=[ArticleInline])
|
||||
@@ -184,6 +198,7 @@ admin.site.register(ModelWithStringPrimaryKey)
|
||||
admin.site.register(Color)
|
||||
admin.site.register(Thing, ThingAdmin)
|
||||
admin.site.register(Persona, PersonaAdmin)
|
||||
admin.site.register(Parent, ParentAdmin)
|
||||
|
||||
# We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2.
|
||||
# That way we cover all four cases:
|
||||
|
||||
Reference in New Issue
Block a user