def ad_view(request, id):
    ad = get_object_or_404(AdBase, id=id)

    click = AdClick.objects.create(
        ad=ad,
        click_date=datetime.now(),
        source_ip=request.META.get('REMOTE_ADDR', '')
    )
    click.save()

    redirect_url = ad.url
    if not redirect_url.startswith('http://'):
        # Add http:// to the url so that the browser redirects correctly
        redirect_url = 'http://' + redirect_url

    return HttpResponseRedirect(redirect_url)
Record the click in the database, then redirect to ad url
dataset/ETHPy150Open andrewebdev/django-adzone/adzone/views.py/ad_view