Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Ads Management System for Django Framework

Project Description

a Django Application to make it easy to add Simple (Image) Advertisements to your project.

Each Ad has a title, a URL to redirect to, an image to be displayed in the template as a link, a start & end dates, and a weight relative to other Ads in the same zone. The higher the weight, the more frequently the Ad will be displayed.

Each time an Ad is displayed an Impression will be saved to the database about it with session id and source ip address, and each time it will be clicked a click will be saved in the database about it with the same info.


Install the package using pip:

pip install django-ads

Run django Migration to add tables to your database:

python migrate ads


Add 'ads' to your INSTALLED_APPS

Make sure django.template.context_processors.request is included in context_processors

        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [

Make sure django.contrib.sessions.middleware.SessionMiddleware is included to MIDDLEWARE_CLASSES/MIDDLEWARE

Prior to Django 1.10


Django 1.10 (new style)


Add the following to your settings file:

ADS_GOOGLE_ADSENSE_CLIENT = 'ca-pub-xxxxxxxxxxxxxxxx'  # OPTIONAL - DEFAULT TO None

    'header': {
        'name': _('Header'),
        'ad_size': '800x90',
        'google_adsense_slot': 'xxxxxxxxx',  # OPTIONAL - DEFAULT TO None
        'google_adsense_format': 'auto',  # OPTIONAL - DEFAULT TO None
    'content': {
        'name': _('Content'),
        'ad_size': '500x90',
        'google_adsense_slot': 'xxxxxxxxx',  # OPTIONAL - DEFAULT TO None
        'google_adsense_format': 'auto',  # OPTIONAL - DEFAULT TO None
    'sidebar': {
        'name': _('Sidebar'),
        'ad_size': '270x270'
        'google_adsense_slot': 'xxxxxxxxx',  # OPTIONAL - DEFAULT TO None
        'google_adsense_format': 'auto',  # OPTIONAL - DEFAULT TO None

Where each element in ADS_ZONES defines a zone that can be used in your templates to display ads. Each zone must have a name to be used in admin interface when adding ads, and a size to be used to resize images in tempaltes using easy-thumbnails.


Add Advertisers, Categories, and Ads using Django admin interface.

load ads_tags in your template:

{% load ads_tags %}

use render_ads_zone in your template where you want your ads to appear:

{% render_ads_zone 'zone_name' %}


0.1.8 (2017-06-24):

  • fix googleads script tags to load multiple ad units in the same page

0.1.7 (2017-06-24):

  • Please do not use this version

0.1.6 (2017-06-24):

  • fix django-sekizai dependency version

0.1.5 (2017-06-24):

  • add google adsense fallback

0.1.4 (2017-03-01):

  • get client ip address from HTTP_X_FORWARDED_FOR if it exists.

0.1.3 (2017-02-08):

  • remove dependency on easy-thumbnails.
  • add Image validation to validate image size on upload using Admin interface.

0.1.2 (2017-02-08):

  • add AdImage model to allow responsive ads.

0.1.1 (2016-12-20):

  • add missing templates directory.
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-ads-0.1.8.tar.gz (12.9 kB) Copy SHA256 Checksum SHA256 Source Jun 24, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting