def get_formfield(model, field):
    """
    Return the formfied associate to the field of the model
    """
    class_field = model._meta.get_field(field)

    if hasattr(class_field, "field"):
        formfield = class_field.field.formfield()
    else:
        formfield = class_field.formfield()
    
    # Otherwise the formfield contain the reverse relation
    if isinstance(formfield, ChoiceField):
        formfield.choices = class_field.get_choices()
    
    return formfield
Return the formfied associate to the field of the model