def get_primary_key(model):
    """Get the name of the field in a model that has primary_key=True"""
    model = get_model(model)
    return (field.name for field in model._meta.fields if field.primary_key).next()