(field_name, model)
Given a field_name and model, checks if field is ForeignKey or OneToOneField or not.
Given a field_name and model, checks if field is ForeignKey or OneToOneField or not.
Given a field_name and model checks if field is ForeignKey or OneToOneField or not .
def is_foreignkey(field_name, model):
    """
        Given a field_name and model, checks if field is ForeignKey or OneToOneField or not.
    """
    try:
        field = model._meta.get_field(field_name)
        if field.get_internal_type() in ["ForeignKey", "OneToOneField"]:
            return True
        return False
    except FieldDoesNotExist:
        return False
def is_foreignkey ( field_name , model ) : try : field = model . _meta . get_field ( field_name ) if field . get_internal_type ( ) in [ "ForeignKey" , "OneToOneField" ] : return True return False except FieldDoesNotExist : return False