mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Check for a not-None pk for ExcludeFieldsOnEditMixin to avoid catching non-saved instance binding
This commit is contained in:
parent
2db605df09
commit
31e9572598
@ -809,8 +809,8 @@ class ExcludeFieldsOnEditMixin:
|
||||
|
||||
def bind_to(self, *args, **kwargs):
|
||||
new = super(ExcludeFieldsOnEditMixin, self).bind_to(*args, **kwargs)
|
||||
# when binding to an existing instance - ie editing - set those fields in the form to disabled
|
||||
if new.form and new.instance and hasattr(new.model, 'exclude_on_edit'):
|
||||
# when binding to an existing instance with a pk - ie editing - set those fields in the form to disabled
|
||||
if new.form and new.instance and new.instance.pk is not None and hasattr(new.model, 'exclude_on_edit'):
|
||||
for field in new.model.exclude_on_edit:
|
||||
try:
|
||||
new.form.fields[field].disabled = True
|
||||
|
Loading…
Reference in New Issue
Block a user