Risolto errore che impediva il salvataggio in presenza di campi della form
estranei o property dell'adminmain
parent
5a085012c5
commit
075f507412
|
|
@ -28,6 +28,7 @@ from admin_confirm.constants import (
|
||||||
CACHE_TIMEOUT,
|
CACHE_TIMEOUT,
|
||||||
)
|
)
|
||||||
from admin_confirm.file_cache import FileCache
|
from admin_confirm.file_cache import FileCache
|
||||||
|
from django.core.exceptions import FieldDoesNotExist
|
||||||
|
|
||||||
|
|
||||||
class AdminConfirmMixin:
|
class AdminConfirmMixin:
|
||||||
|
|
@ -189,8 +190,13 @@ class AdminConfirmMixin:
|
||||||
# It could be incorrect when user hits save, and then hits "No, go back to edit"
|
# It could be incorrect when user hits save, and then hits "No, go back to edit"
|
||||||
obj.refresh_from_db()
|
obj.refresh_from_db()
|
||||||
|
|
||||||
|
try:
|
||||||
field_object = model._meta.get_field(name)
|
field_object = model._meta.get_field(name)
|
||||||
initial_value = getattr(obj, name)
|
initial_value = getattr(obj, name)
|
||||||
|
except (AttributeError, FieldDoesNotExist) as e :
|
||||||
|
print(e)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
# Note: getattr does not work on ManyToManyFields
|
# Note: getattr does not work on ManyToManyFields
|
||||||
if isinstance(field_object, ManyToManyField):
|
if isinstance(field_object, ManyToManyField):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue