Friday, December 24, 2010

Getting postgis to work with django (and sphinx)

The django-sphinx package does not recognize the postgis backend; one needs to modify the /path/to/djangosphinx/utils/ and reinstall it to make the two work together. Add the following to _get_database_engine() in the file:

def _get_database_engine():
elif 'postgis' in settings.DATABASES['default']['ENGINE']:
return 'pgsql'

If you are creating a database as the default superuser postgres but you will be connecting to the database as a different user (say chineseblade), it is necessary to grant the privileges to the user. Sadly, if you use template_postgis as a template in creating the database, you will need to grant accesses to the tables geometry_columns and spatial_ref_sys individually, in addition to granting privileges on the database itself. The procedure is

Log on to the database template_postgis as the superuser postgres, and issue commands:

grant select on table spatial_ref_sys to chineseblade;
grant all on table geometry_columns to chineseblade;

Log out, then log on the master database postgres, and create the database using the template:

create database mydb with template=template_postgis;
grant all privileges on database mydb to chineseblade;

Now in the in your project, set the database engine to 'django.contrib.gis.db.backends.postgis'. You are ready to go!

1 comment:

  1. A gambling game that you can play every day.

    Gclub The casino will give gamblers the chance to find the full bet. Played very well Gambling is a live casino game. Bring it to everyone to play it realistically. There are many investments. Make huge profits. Where to play gambling every day. New bets. Have fun at any time like Gambling helps players find the number one bet. Gambling Wherever You Are It is ready to play the luck as anyone can play well.

    In addition, the gambler to invest in the online casino gambling at our website. In addition, investors will invest in your favorite gambling games. Investors will also get a lot of promotions that we have been held for the player to get here. Investors who are interested to subscribe to our website, then the player can invest in our online gambling services at this player will not be disappointed in this game. The gambler will play simple with our online casino gambling site standard. The gambler will not be disappointed by the chance we have to open the player for sure. Royal1688