human
Complete this python program:
def cache_model(model, timeout=None):
assistant
#Here is the Python code you requested.

    """Adds utility methods to the given model to obtain
    ``ForeignKey`` instances via the cache.
    """
    if hasattr(model, 'get_cached'):
        return
    def clear_cache(sender, instance, *args, **kwargs):
        '\n                                Clears    the    cache    for    the    given    instance.\n                                '
        delete_instance(sender, instance)
    post_save.connect(clear_cache, sender=model, weak=False)
    post_delete.connect(clear_cache, sender=model, weak=False)
    @classmethod
    def get(cls, pk, using=None):
        '\n                                Returns    the    model    for    the    given    primary    key    (pk).\n                                '
        if (pk is None):
            return None
        return get_instance(cls, pk, timeout, using)
    model.get_cached = get