django - get field which name is dynamic

Viewed 10018

What I need: I want to get object details from DB. I use get() function. The problem I have is, that I make in in a function, and one of the arguments is field name as string:

def delete_file_if_changed(id, change, form, model, field_name='image'):
    if change:
        if field_name in form.changed_data:
            old_image = model.objects.get(pk__exact=id)

Now - how can I do the thing that I can get old_image.field_name - how to do that?

3 Answers
Related