def relative_url(value, field_name, url_encode=None):
    """
    This snippet comes from the website simpleifbetterthancomplex.com and was made by Vitor Freitas, as part of his
    article “Dealing with querystring parameters” (published on 22th 08/2016, read the 12/05/2016)

    :param value: the parameter to add to the existing query string
    :param field_name: the name of the parameter
    :param url_encode: the existing query string
    :return: a new querystring with the new parameter.
    """
    url = '?{}={}'.format(field_name, value)
    if url_encode:
        querystring = url_encode.split('&')
        filtered_querystring = filter(lambda p: p.split('=')[0] != field_name, querystring)
        encoded_querystring = '&'.join(filtered_querystring)
        url = '{}&{}'.format(url, encoded_querystring)
    return url