﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21547	GeoDjango admin throws ProgrammingError after following the tutorial	awilliams@…	nobody	"Hi guys. This is my first bug report so please let me know how I can improve it. I'm still new to the world of GeoDjango, but I did successfully upgrade an existing GeoDjango 1.5 application to 1.6 without any hiccups. I'm only seeing this problem when I create a '''new''' projects. This is using the default Django 1.6 project and app structure.


== The Problem ==
The GeoDjango admin for the ""world"" app created in the GeoDjango tutorial throws a ProgrammingError:
{{{
ProgrammingError at /admin/world/worldborder/
column world_worldborder.geom does not exist
LINE 1: ...ld_worldborder"".""lon"", ""world_worldborder"".""lat"", ""world_wor...
}}}

== Reproduce the problem ==
1. Visit the GeoDjango tutorial for Django 1.6 https://docs.djangoproject.com/en/1.6/ref/contrib/gis/tutorial/

2. Create a database with GIS extensions https://docs.djangoproject.com/en/1.6/ref/contrib/gis/install/postgis/#creating-a-spatial-database-with-postgis-2-0-and-postgresql-9-1

3. Create the ""world"" app described https://docs.djangoproject.com/en/1.6/ref/contrib/gis/tutorial/#create-a-new-project

4. Follow the steps up to '''Put your data on the map'''. Run {{{ python manage.py runserver }}}.

5. Visit http://127.0.0.1:8000/admin/world/worldborder/ to see the error.

== Notes ==
* Most of the tutorial works as described. it's only the admin section that throws an error.
* The output from {{{ python manage.py sqlall world }}} is different than the tutorial:
{{{#!sql
BEGIN;
CREATE TABLE ""world_worldborder"" (
    ""id"" serial NOT NULL PRIMARY KEY,
    ""name"" varchar(50) NOT NULL,
    ""area"" integer NOT NULL,
    ""pop2005"" integer NOT NULL,
    ""fips"" varchar(2) NOT NULL,
    ""iso2"" varchar(2) NOT NULL,
    ""iso3"" varchar(3) NOT NULL,
    ""un"" integer NOT NULL,
    ""region"" integer NOT NULL,
    ""subregion"" integer NOT NULL,
    ""lon"" double precision NOT NULL,
    ""lat"" double precision NOT NULL,
    ""mpoly"" geometry(MULTIPOLYGON,4326) NOT NULL
)
;
CREATE INDEX ""world_worldborder_mpoly_id"" ON ""world_worldborder"" USING GIST ( ""mpoly"" );

COMMIT;

}}}
Output in tutorial: https://docs.djangoproject.com/en/1.6/ref/contrib/gis/tutorial/#run-syncdb

== Development setup ==
* Ubuntu 12.10
* Python 2.7.3
* Django 1.6
* PostGIS 2.0.1
* PostgreSQL 9.1.10
* Virtualenvwrapper 4.1.1
* Virtualenv 1.10.1

The stacktrace:
{{{
Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/admin/world/worldborder/

Django Version: 1.6
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.gis',
 'world')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/core/handlers/base.py"" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/contrib/admin/options.py"" in wrapper
  430.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/utils/decorators.py"" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/views/decorators/cache.py"" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/contrib/admin/sites.py"" in inner
  198.             return view(request, *args, **kwargs)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/utils/decorators.py"" in _wrapper
  29.             return bound_func(*args, **kwargs)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/utils/decorators.py"" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/utils/decorators.py"" in bound_func
  25.                 return func(self, *args2, **kwargs2)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/contrib/admin/options.py"" in changelist_view
  1409.             'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/db/models/query.py"" in __len__
  77.         self._fetch_all()
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/db/models/query.py"" in _fetch_all
  854.             self._result_cache = list(self.iterator())
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/db/models/query.py"" in iterator
  220.         for row in compiler.results_iter():
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py"" in results_iter
  710.         for rows in self.execute_sql(MULTI):
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py"" in execute_sql
  781.         cursor.execute(sql, params)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/db/backends/util.py"" in execute
  69.             return super(CursorDebugWrapper, self).execute(sql, params)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/db/backends/util.py"" in execute
  53.                 return self.cursor.execute(sql, params)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/db/utils.py"" in __exit__
  99.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File ""/home/aaron/Envs/development/local/lib/python2.7/site-packages/django/db/backends/util.py"" in execute
  53.                 return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /admin/world/worldborder/
Exception Value: column world_worldborder.geom does not exist
LINE 1: ...ld_worldborder"".""lon"", ""world_worldborder"".""lat"", ""world_wor...
                                                             ^
}}}"	Cleanup/optimization	closed	Documentation	1.6	Normal	fixed	geodjango, gis, postgis 2.0		Accepted	0	0	0	0	0	0
