mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #15424 -- Corrected lookup of callables listed in admin inlines' readonly_fields by passing the right ModelAdmin (sub)class instance when instantiating inline forms admin wrappers. Also, added early validation of its elements. Thanks kmike for the report and Karen for the patch fixing the issue.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15650 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -151,3 +151,43 @@ class TitleInline(admin.TabularInline):
|
||||
extra = 1
|
||||
|
||||
admin.site.register(TitleCollection, inlines=[TitleInline])
|
||||
|
||||
# Models for #15424
|
||||
|
||||
class Poll(models.Model):
|
||||
name = models.CharField(max_length=40)
|
||||
|
||||
class Question(models.Model):
|
||||
poll = models.ForeignKey(Poll)
|
||||
|
||||
class QuestionInline(admin.TabularInline):
|
||||
model = Question
|
||||
readonly_fields=['call_me']
|
||||
|
||||
def call_me(self, obj):
|
||||
return 'Callable in QuestionInline'
|
||||
|
||||
class PollAdmin(admin.ModelAdmin):
|
||||
inlines = [QuestionInline]
|
||||
|
||||
def call_me(self, obj):
|
||||
return 'Callable in PollAdmin'
|
||||
|
||||
class Novel(models.Model):
|
||||
name = models.CharField(max_length=40)
|
||||
|
||||
class Chapter(models.Model):
|
||||
novel = models.ForeignKey(Novel)
|
||||
|
||||
class ChapterInline(admin.TabularInline):
|
||||
model = Chapter
|
||||
readonly_fields=['call_me']
|
||||
|
||||
def call_me(self, obj):
|
||||
return 'Callable in ChapterInline'
|
||||
|
||||
class NovelAdmin(admin.ModelAdmin):
|
||||
inlines = [ChapterInline]
|
||||
|
||||
admin.site.register(Poll, PollAdmin)
|
||||
admin.site.register(Novel, NovelAdmin)
|
||||
|
||||
Reference in New Issue
Block a user