You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I edit PickledObjectField's in admin using editable=True flag where the assigned widget is a textbox. So I have to add the following line to my admin class: formfield_overrides = {PickledObjectField: {'widget': widgets.AdminTextareaWidget}, }
I think it'd be nice if this was the default behaviour.
The text was updated successfully, but these errors were encountered:
BarnabasSzabolcs
changed the title
Admin editable widget should be TextArea
Make admin editable widget a TextArea
Oct 2, 2019
import ast
from django.contrib.admin import widgets
from picklefield.fields import dbsafe_encode
class PickledObjectFieldAdminTextAreaWidget(widgets.AdminTextareaWidget):
def value_from_datadict(self, data, files, name):
value = data.get(name)
# we gotta have a PickledObject here otherwise CharField cleaning kicks in
return dbsafe_encode(ast.literal_eval(value), False, 2, True)
and
class MyAdmin(admin.ModelAdmin):
formfield_overrides = { PickledObjectField: {'widget': PickledObjectFieldAdminTextAreaWidget},}
I edit PickledObjectField's in admin using editable=True flag where the assigned widget is a textbox. So I have to add the following line to my admin class:
formfield_overrides = {PickledObjectField: {'widget': widgets.AdminTextareaWidget}, }
I think it'd be nice if this was the default behaviour.
The text was updated successfully, but these errors were encountered: