I must create a application on Django platform.


To produce a web page which shows the Geo location through the user Ip i.e. (GeoIP) on the internet map.

I'm beginner for Django. I simply attempted an easy application the industry Django official tutorial.

You do not really should use django for this. That you can do with only using client side scripting. I designed a working example for you personally:

<!DOCTYPE html>
    <script src="http://maps.google.com/maps?file=api&v=2&key=abcdefg" type="text/javascript"></script>

    <script language="javascript">
        var lat=50;
        var lon=-110;

        //this is a simple google maps window
        //if you want to add more features look for
        //google maps api documentation 
        function load() {
          if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map"));
            map.setCenter(new GLatLng(lat, lon), 13);
        //this is my show map function with specific coordinates
        function map(position) {
            // first we update our long and lat
            lat = position.coords.latitude;
            //and show the new map
            lon = position.coords.longitude;
        //this function retrieves the position data from browser
        function get_location() {

<body onload="load()" onunload="GUnload()">
<span style=" font-family:Verdana; background-color:#95877f; cursor:default;" onclick="get_location();">Find me!</span>
<div id="map" style="width: 400px; height: 400px"></div>

There's a Python module for IP geolocation. I made use of this inside a recent project which is things i emerged with:

import GeoIP

def geolocate(request):
    # Find the user
    ip = request.META['REMOTE_ADDR']
    if ((not ip) or ip == '') and request.META.has_key('HTTP_X_FORWARDED_FOR'):
        ip = request.META['HTTP_X_FORWARDED_FOR']

    # Get country
    country = g.country_code_by_addr(ip)

    return HttpResponse("I know where you live! " + str(country))

Edit: The above mentioned code is only going to work when the user is asking for the page from the public IP adress. If you are browsing inside a private network, on allows say a 192.168.?.? adress, it'll neglect to locate you and also throw exceptions.