

def ad_view(request, id):
    ' Record the click in the database, then redirect to ad url '
    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://')):
        redirect_url = ('http://' + redirect_url)
    return HttpResponseRedirect(redirect_url)

dataset/ETHPy150Open andrewebdev/django-adzone/adzone/views.py ad_view/original