Something like
my_model.data_dict['my_field']
Which would give you the current value for that field? Need something like that to interface with my other code.
Something like
my_model.data_dict['my_field']
Which would give you the current value for that field? Need something like that to interface with my other code.
It's lil tricky but you can do it like this:
def model2dict(obj):
return dict([(field, getattr(obj, field)) for field in obj._meta.get_all_field_names()])
So you can access values:
model2dict(my_model)['my_field']