I am new to Geodjango. and I am following the steps given in https://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/#

and the steps i followed before https://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/#spatial-queries were working fine but after that I got error in the

qs = WorldBorder.objects.filter(mpoly__contains=pnt_wkt)

in this Statement.

Error it is showing is

FieldError: Cannot resolve keyword 'mpoly' into field. Choices are: area, fips, geom, id, 
iso2, iso3, lat, lon, name, pop2005, region, subregion, un

and if I am executing this line

sm = WorldBorder.objects.get(name='San Marino')

Then Error is

DatabaseError: column world_worldborder.geom does not exist
LINE 1: ...ld_worldborder"."lon", "world_worldborder"."lat", "world_wor...

Kindly Help ..



You changed your schema and the underlying tables did not get updated. When I develop on Django, I usually change my schema quite often. Unless you want to manually sync your fields through raw SQL (or even worse - drop the tables and re-create them), I would recommend you use South which is the de facto standard to keep your Django models and your DB in sync.


From my tiny experience with GeoDjango, you must sync your daatabase quite often until you fully define your model.

Why don't you try dropping all tables created by django and then recreating them via syncdb?

I'm not sure if that might help, but these are basic column errors, so that might help out. On the other side, can you start up the django dev server using runserver? The runserver command validates all models against database (remember that you application must be listed in settings.py).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.