mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #9122: generic inline formsets now respect exclude and max_num. Thanks, Alex Robbins.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10586 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
002e3fd9e4
commit
a075422bfc
4 changed files with 109 additions and 3 deletions
|
@ -20,11 +20,55 @@ class Media(models.Model):
|
|||
|
||||
class MediaInline(generic.GenericTabularInline):
|
||||
model = Media
|
||||
extra = 1
|
||||
|
||||
class EpisodeAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
MediaInline,
|
||||
]
|
||||
|
||||
admin.site.register(Episode, EpisodeAdmin)
|
||||
|
||||
#
|
||||
# These models let us test the different GenericInline settings at
|
||||
# different urls in the admin site.
|
||||
#
|
||||
|
||||
#
|
||||
# Generic inline with extra = 0
|
||||
#
|
||||
|
||||
class EpisodeExtra(Episode):
|
||||
pass
|
||||
|
||||
class MediaExtraInline(generic.GenericTabularInline):
|
||||
model = Media
|
||||
extra = 0
|
||||
|
||||
admin.site.register(EpisodeExtra, inlines=[MediaExtraInline])
|
||||
|
||||
#
|
||||
# Generic inline with extra and max_num
|
||||
#
|
||||
|
||||
class EpisodeMaxNum(Episode):
|
||||
pass
|
||||
|
||||
class MediaMaxNumInline(generic.GenericTabularInline):
|
||||
model = Media
|
||||
extra = 5
|
||||
max_num = 2
|
||||
|
||||
admin.site.register(EpisodeMaxNum, inlines=[MediaMaxNumInline])
|
||||
|
||||
#
|
||||
# Generic inline with exclude
|
||||
#
|
||||
|
||||
class EpisodeExclude(Episode):
|
||||
pass
|
||||
|
||||
class MediaExcludeInline(generic.GenericTabularInline):
|
||||
model = Media
|
||||
exclude = ['url']
|
||||
|
||||
admin.site.register(EpisodeExclude, inlines=[MediaExcludeInline])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue