def get_context(package, prefix=None):
    """Get entire @context, or a single IRI, from ``package``.

    :param package: queried package to get values from
    :type package: django.db.models.query.QuerySet
    :param prefix: prefix of IRI value inside package @context
    :type prefix: str
    :return: One or all IRI values from package @context
    :rtype: dict[str,str] or str
    :raises ValueError: Unable to retrieve @context somehow
    """
    if package.count() != 1:
        raise ValueError('Please query an appropriate package')

    if prefix is None:
        query = 'contents__@context'
    else:
        query = 'contents__@context__' + prefix

    #print ("query", query)
    #print ("package.values_list", package.values_list('contents__metadata', flat=True)[0])
    ret = package.values_list(query, flat=True)[0]

    if prefix is not None and ret is None:
        raise ValueError(prefix + ' not found in package')

    return ret