On Sat, Jun 9, 2012 at 12:14 AM, jstratm <jstr...@googlemail.com> wrote:
> I posted this over at bitnami too, but perhaps the issue is not with
> the stack and is simply a general user error (highly likely!)
>
> I have been struggling now for about two days to get a GeoDjango/
> PostGIS project started.  Sorry to say, I am fairly new to both Django
> and Linux, but I will do my best to explain what I have tried thus
> far.
>
> First, my assumption: This self contained bitnami djangostack package
> already has everything internally to do a basic Geodjango/PostGIS
> project (I have looked through directories and see them all, but maybe
> they still must be installed?? hmm).  Please let me know if this is
> incorrect.
>
> I am following https://docs.djangoproject.com/en/1.4/ref/contrib/gis/tutorial/
> My steps:
>
> -Installed DjangoStack on Ubunutu 12.4 via the GUI, with all 3 DBs, no
> initial project set up
> -Open up and exclusively work from “use_djangostack” terminal
> -followed the link for “spatial database template” to
> https://docs.djangoproject.com/en/1.4/ref/contrib/gis/install/#spatialdb-template,
> followed directions there:
>        -was NOT able to execute the command “$ sudo su – postgres” (“unknown
> id”) to switch to being a “privileged database user,” BUT I could
> still (mostly) successfully execute:
>        $ POSTGIS_SQL_PATH=/home/jstratman/djangostack-1.4-1/postgresql/share/
> contrib/postgis-        2.0
>        $ createdb -E UTF8 template_postgis
>        $ createlang -d template_postgis plpgsql # Adding PLPGSQL language
> support.
>        (^this command was unsuccessful, stating it already had this language
> support)
>        $ psql -d postgres -c "UPDATE pg_database SET datistemplate='true'
> WHERE   datname='template_postgis';"
>        $ psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
>        $ psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
>        $ psql -d template_postgis -c "GRANT ALL ON geometry_columns TO
> PUBLIC;"
>        $ psql -d template_postgis -c "GRANT ALL ON geography_columns TO
> PUBLIC;"
>        $ psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO
> PUBLIC;"
> -Moved back to main tutorial page, executed:
>        $ createdb -T template_postgis mysitedatabase
>        $ sudo su – postgres (tried again, NOT SUCCESSFUL! “unknown id”)
>        $ createuser --createdb mysiteuser
>        $ django-admin.py startproject mysite (I stayed in the main
> directory, did not create this in “Apps>Django>Django_Projects”)
>        $ cd mysite
>        $ python manage.py startapp world
> -I then set up the settings.py:
>        DATABASES = {
>    'default': {
>         'ENGINE': 'django.contrib.gis.db.backends.postgis',
>         'NAME': 'mysitedatabase',
>         'USER': 'mysiteuser',
>     }
> }
> INSTALLED_APPS = (
>    'django.contrib.auth',
>    'django.contrib.contenttypes',
>    'django.contrib.sessions',
>    'django.contrib.sites',
>    'django.contrib.messages',
>    'django.contrib.staticfiles',
>    'django.contrib.admin',
>    'django.contrib.gis',
>    'world'
> )
> -I did try adding 'PASSWORD' to the settings.py on my second try but
> that made no difference once I got to the syncdb (see below)
> -Installed world borders shp files in world/data
> -Used both ogrinfo commands and got proper results
> -exactly copied and pasted into world/models.py from the “Defining a
> Geographic Model” section, to include the very top line of “from
> django.contrib.gis.db import models
> “
> The Error:
> -Attempted to run “$ python manage.py sqlall world” but got:
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "manage.py", line 10, in <module>
>    execute_from_command_line(sys.argv)
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/core/management/__init__.py", line 443, in
> execute_from_command_line
>    utility.execute()
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/core/management/__init__.py", line 382, in
> execute
>    self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/core/management/__init__.py", line 261, in
> fetch_command
>    klass = load_command_class(app_name, subcommand)
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/core/management/__init__.py", line 69, in
> load_command_class
>    module = import_module('%s.management.commands.%s' % (app_name,
> name))
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/utils/importlib.py", line 35, in import_module
>    __import__(name)
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/core/management/commands/sqlall.py", line 4, in
> <module>
>    from django.core.management.sql import sql_all
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/core/management/sql.py", line 6, in <module>
>    from django.db import models
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/db/__init__.py", line 40, in <module>
>    backend = load_backend(connection.settings_dict['ENGINE'])
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/db/__init__.py", line 34, in __getattr__
>    return getattr(connections[DEFAULT_DB_ALIAS], item)
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/db/utils.py", line 92, in __getitem__
>    backend = load_backend(db['ENGINE'])
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/db/utils.py", line 24, in load_backend
>    return import_module('.base', backend_name)
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/utils/importlib.py", line 35, in import_module
>    __import__(name)
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/contrib/gis/db/backends/postgis/base.py", line 5,
> in <module>
>    from django.contrib.gis.db.backends.postgis.operations import
> PostGISOperations
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/contrib/gis/db/backends/postgis/operations.py",
> line 8, in <module>
>    from django.contrib.gis.geometry.backend import Geometry
>  File "/home/jstratman/djangostack-1.4-1/apps/django/lib/python2.7/
> site-packages/django/contrib/gis/geometry/backend/__init__.py", line
> 14, in <module>
>    '"%s".' % geom_backend)
> django.core.exceptions.ImproperlyConfigured: Could not import user-
> defined GEOMETRY_BACKEND "geos".
> ----------------------------------------------------------------------
>
> Sorry this is so long, but I wanted full disclosure to perhaps
> highlight simple, new user errors.  Any ideas as to why it can't
> utilize the geos backend or whatever the problem is?
>
>
>


The short response is that you need to add in the settings.py
(geodjango/geodjango/setting.py) the path to the geos library. In your
case you need to add the following:

GEOS_LIBRARY_PATH =
'/home/jstratman/djangostack-1.4-1/postgresql/lib/libgeos_c.so'

Now if you run "python manage.py sqlall world" it should work.

But now a few comments on the steps that you followed and the errors you got.

"sudo su - postgres" fails becuase it seems that you installed the
stack as a non root user and the postgres user doesn't exist in your
system. We only configure PostgreSQL to run as postgres when it is
installed as root.

For creating the template_postgis on PostgreSQL 9.x and Postgis 2.0
(the configuration in BitNami) you can also check .

I already replied to the BitNami forums also.

>
>
>
>
>
>
> -
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to