Overview

README

This repository is a fork of gregplaysguitar's django-countryip repository: https://github.com/gregplaysguitar/django-countryip/

gregplaysguitar's version is improved fork of the original code from smileychris: http://code.google.com/p/django-countryip/

This version of countryip Django app is packaged as an egg and can be used or further developed using buildout.

= Current version =

countryip-1.4.tgz built on December 6 2011 by Marek Kuziel (http://bitbucket.org/vshivak/django-countryip/)

http://bitbucket.org/vshivak/django-countryip/raw/tip/pypi/countryip-1.4.tar.gz

= Build and Install =

  • egg
  • buildout
  • buildout devel

== egg ==

build.sh - builds a development egg in dist directory as tar.gz

== buildout ==

Integrate the following bits into your builtout configuration file to include countryip:

[buildout]

find-links =
http://bitbucket.org/vshivak/django-countryip/raw/tip/pypi/countryip-1.4.tar.gz
eggs =
countryip

== buildout devel ==

Clone the repository into your virtualenv:

cdvirtualenv src; hg clone http://bitbucket.org/vshivak/django-countryip/ countryip

Integrate the following bits into your builtout configuration file to include countryip development egg:

[buildout]

develop =
src/countryip

= Usage =

== Setup ==

  • Put countryip on the PYTHONPATH. See builtout section above.
  • Add countryip to your Django project's INSTALLED_APPS settings.
  • Add django.core.context_processors.request into TEMPLATE_CONTEXT_PROCESSORS settings. This is required in order to get template tag working.
  • Add countryip.middleware.SetRemoteAddrFromForwardedFor into MIDDLEWARE_CLASSES settings. This is required in order to get template tag working when a project instances run behind reverse proxy.

== Load GeoIPCountry Data ==

== Use ==

In a view:

Country.objects.for_ip(request.META['REMOTE_ADDR'])

In a template, use

{% load countryip_tags %}

{% get_country as country %}

{% ifequal country.code 'NZ' %}
Kia Ora, Welcome!
{% else %}
Hello world!

{% endifequal %}

= Thanks =

Thanks to smileychris for the original version of this software.

Thanks to gregplaysguitar for the code updates.