Skip to content

Conversation

fcurella
Copy link
Contributor

ref https://code.djangoproject.com/ticket/25379#ticket

Update GeoDjango tutorial to Postgres 9.1+ and CreateExtension

The GeoDjango tutorial (https://docs.djangoproject.com/en/1.8/ref/contrib/gis/tutorial/) still instructs to create a db using the spatial template.

Since PostgresSQL 9.1, the preferred way is to use the postgis extension instead.

This brings up another issue: should makemigrations automatically add a CreateExtension operation? Is that even doable?

For now I've simply documented it, but it would be very handy to have it automatically.

@timgraham
Copy link
Member

It should be done automatically as of Django 1.8 (bac7664). Did you test it?

@timgraham timgraham changed the title Close #25379. Updated GeoDjango tutorial Fixed #25379 -- Added CreateExtension to GeooDjango tutorial. Sep 10, 2015
@fcurella
Copy link
Contributor Author

I did try on master (0cc0e67), and it does not add the CreateExtension operation. I've checked the output of sqlmigrate and did not contain any CREATE EXTENSION. My database engine is set to 'django.contrib.gis.db.backends.postgis'

@timgraham
Copy link
Member

Looking at the implementation, it wouldn't appear in sqlmigrate or add the operation to the migration, but the appropriate SQL should be run when running migrate. Did you see the commit I linked? If you could debug why it's not working (if that's the case), that'd be great.

@fcurella
Copy link
Contributor Author

I've verified and migrate does indeed create the extension (I can see it with \dx on psql).

I'll amend my commit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Django 1.9 drops support for PostgreSQL 9.0, so this is obsolete.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case, I'm not sure the special mention about how to create a database in PostgreSQL is needed (given the other databases aren't mentioned). What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I've removed the whole sentence

@fcurella fcurella changed the title Fixed #25379 -- Added CreateExtension to GeooDjango tutorial. Fixed #25379 -- Update GeoDjango tutorial to Postgres 9.1+ Sep 10, 2015
@fcurella
Copy link
Contributor Author

While we're here, shuold we suggest Postgres.app under https://github.com/django/django/blob/master/docs/ref/contrib/gis/install/index.txt#L211 ?

@timgraham
Copy link
Member

I don't know anything about that (don't use OSX), but I think that section is likely outdated so if you think there are new best practices, I'm sure an update to that section would be welcome. Seems like a separate ticket though.

@timgraham timgraham changed the title Fixed #25379 -- Update GeoDjango tutorial to Postgres 9.1+ Fixed #25379 -- Removed obsolete information from GeoDjango tutorial. Sep 11, 2015
@timgraham
Copy link
Member

merged in dfced09, thanks!

@timgraham timgraham closed this Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants