def _get_model_form_field(model, name, formfield_callback=None, **kwargs):
    """
    Utility to create the formfield from a model field.
    When a field is not editable, a ``None`` will be returned.
    """
    field = model._meta.get_field(name)
    if not field.editable:  # see fields_for_model() logic in Django.
        return None

    # Apply admin formfield_overrides
    if formfield_callback is None:
        formfield = field.formfield(**kwargs)
    elif not callable(formfield_callback):
        raise TypeError('formfield_callback must be a function or callable')
    else:
        formfield = formfield_callback(field, **kwargs)

    return formfield
def _get_model_form_field ( model , name , formfield_callback = None , ** kwargs ) : field = model . _meta . get_field ( name ) if not field . editable : return None if formfield_callback is None : formfield = field . formfield ( ** kwargs ) elif not callable ( formfield_callback ) : raise TypeError ( 'formfield_callback must be a function or callable' ) else : formfield = formfield_callback ( field , ** kwargs ) return formfield
Utility to create the formfield from a model field.
    When a field is not editable, a ``None`` will be returned.