Closed alphydan closed 9 years ago
My solution for this was to create a custom form and use it in the admin. It inherits from forms.ModelForm like so:
class MyModelAdminForm(forms.ModelForm):
picked_field = forms.CharField(widget=forms.Textarea())
class Meta:
model = MyModel
fields = ['pickled_field', 'other_field',...]
def __init__(self, *args, **kwargs):
super(MyModelAdminForm, self).__init__(*args, **kwargs)
self.fields['picked_field'].initial = self.instance.pickled_field
The field is automatically marked as editable=False
hence why it's not displayed in the admin.
Since the HTML form representation of data stored in a PickledObjectField
is highly application dependent and shouldn't be exposed to the end user in most cases I think we shouldn't ship a form field and keep things as they are.
First of all thank you for sharing this code. I think I've taken the appropriate steps but I can't see the field in the admin. Should I be able to see it and edit it?
models.py
admin.py
Any tips appreciated, thank you.