Skip to content
A django application to manage advertising and advertising zones.
Find file
Pull request Compare This branch is 64 commits behind andrewebdev:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


django-adzone Documentation

© Copyright 2009 Andre Engelbrecht. All Rights Reserved.


Please see the LICENCE file for information on the License


Please take note: django-adzone has just gone through a major update. If you have been using the previous version of django-adzone, then you should not upgrade since you are highly likely to break something. You have been warned :)

0.2a is a alpha release. Please test and report any bugs that you may find.

Release Notes

  • AdBase model is no longer abstract
  • Added a manager to the AdBase class which can be used to return specific ads
  • AdBase child models (ie. textad and bannerad) no longer needs a get_absolute_url method
  • Removed the FlashAd model. This will be used in a example on how to create your own ad types (coming soon)
  • The url to view a ad is now a named url pattern, so reverse lookups can be used.
  • The zone_ad template tag is now a inclusion_tag

Concept behind adzone

The concept behind adzone is quite simple. You have certain areas on your website reserved for adverts. The size and
nature of the ads may differ for each of these areas. Adzone allows exactly this kind of functionality, by choosing
which adds belong to certain zones.

Ads are grouped according to 2 criteria

1.The Category

The ad category explains the nature or subject matter for the advert. This can help to specify in which pages of your
site you want a specific group of ads to appear. For example, you have a bunch of ads related to your blog, so you add
them to your Blog category.

2.The Zone

Zone specifies what area on the current page the ad belongs to. If you are displaying a ad on your blog you might have 2
zones, one for content, and one for the right column.

These two grouping criteria provides enough flexability to control what ads will display where. All you need to do is to
use the adzone template tags, to specify categories and zones in your templates.


There are no external requirements for this project.


Installation instructions may vary depending on your environment.
To install system wide however, just run:

python install

How to use

Getting Started

1. Add adzone to your installed apps
2. To make sure that the user IP is recorded on the impressions, add the following to your TEMPLATE_CONTEXT_PROCESSORS:
'adzone.context_processors.get_source_ip' (this is not a requirement for the app to work in general)
3. Add the adzone urls to your project urls: (r'^adzone/', include('adzone.urls')),
4. Remember to run syncdb again :)

Using the built-in template tag to display an ad

To show a specific ad in a template, you can use the built-in template tag.
Lets say you have the following Ad Category and Zone set up in your database (via Admin):
ad category title: ‘General’
ad category slug : ‘general’
ad zone title: ‘Content’
ad zone slug: ‘content’

Now, in your template, you first want to load the tag library:
{% load adzone_tags %}

Next, ad the tag to the specific area where you want the ads to appear:
{% random_zone_ad 'general' 'content' %}

The ads are first filtered by the category and zone slugs you pass to the tag, and then a random ad is returned.

One Tag to rule them all! No seriously, you only need the one tag to display any type of ad, textads or bannerads. This also applies if you decide to create your own types of ads (by extending the AdBase model).

Something went wrong with that request. Please try again.