@register.simple_tag
def render_ad_by_id(ad_id, fallback='True'):
    """
    Renders the requested BannerAd instance. If fallback is 'True', the site will
    display an AdSense ad if there is no current BannerAd with the specified ID and
    of the specified type.
    """
    try:
        ad_id = int(ad_id)
    except:
	ad_id = 0

    try:
        ad = BannerAd.current.get(id=ad_id)
    except BannerAd.DoesNotExist:
        ad = None

    if not ad:
        ad = None
        if fallback == 'True':
            return render_adsense(type)
        else:
            return ''
    
    code = ''
    if not ad.code:
        code = '<img src="%s" alt="%s" />' % (ad.image.url, ad.name)
        if ad.url:
            code = ''.join([ad.url % '<a href="%s">', code, '</a>'])
    else:   
        code = ad.code
    code = ''.join(['<div class="ad ad_%s">' % ad.ad_type, code, '</div>'])
                
    return code
dataset/ETHPy150Open albatrossandco/brubeck_cms/brubeck/advertising/templatetags/advertising.py/render_ad_by_id/swapped operands of `%`