python - Modify variable just in the Django admin but not in database -
i want modify single value when open instance of model in django admin.
want display value opposite of 1 stored in database. here did in admin.py :
class mymodeladminform(forms.modelform): import_file = forms.filefield(required=false) class meta: model = mymodel def __init__(self, *args, **kwargs): super(mymodeladminform, self).__init__(*args, **kwargs) print(self.instance.value) self.instance.value = self.instance.get_reverted_value() print(self.instance.value)
i works can see prints, admin still displays original value stored in database.
idea ?
in advance
what about:
def __init__(self, *args, **kwargs): super(mymodeladminform, self).__init__(*args, **kwargs) self.fields['value'].value = self.instance.get_reverted_value()
Comments
Post a Comment