Jan*_*nis 14 django django-admin django-1.5
我有一些带有大量内联的模型.因为并非所有对象都需要我声明内联模型,extra = 0所以add +内联上出现一个小的.
但是,这似乎不再适用于django 1.5.如果extra = 0设置,则内联不再可编辑.
有没有办法将1.4行为变为1.5?
示例代码:
class ModelInline(admin.StackedInline):
model = MyModel
extra = 0
class OtherModelAdmin(admin.ModelAdmin)
inlines = [ModelInline]
admin.site.register(OtherModel, OtherModelAdmin)
Run Code Online (Sandbox Code Playgroud)
编辑(一些屏幕):
Django 1.4:

Django 1.5:

(Hinzufügen== add)
这已经发生过了.
The new javascript made this impossible because the "Add Another" button
was controlled by max_num, and ignored a value of 0.
The javascript ignored a value of 0 because max_num has a default value of 0,
and all the code using it had taken to equating max_num = 0 with being "off".
So you can't actually have a maximum of 0. It's not possible.
Run Code Online (Sandbox Code Playgroud)
Gabrial Hurley创建了一个补丁,用于恢复所需的行为而不会破坏任何其他内容.这是3年前,我不知道它是否仍然适用于Django 1.5.试一试 :)
https://code.djangoproject.com/attachment/ticket/13023/13023_inlines_patch.diff
这是同一个bug(3年前)的票证:
https://code.djangoproject.com/ticket/13023
| 归档时间: |
|
| 查看次数: |
5673 次 |
| 最近记录: |