Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7589 closed (fixed)

gis: Modifications to Django management commands to support creation of spatial tables.

Reported by: jbronn Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: gis syncdb sql
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This patch contains the following changes that enable the Django management commands to construct spatial SQL for PostGIS:

  1. The addition of the _post_create_sql hook. If a custom field has this function it will be called and its output will precede any other SQL generated by sql.custom_sql_for_model. This works well, but I'm of course open to changes in the function name and/or the possibility of a post_table_create signal or something (doing after post_syncdb will not work).
  1. Although not required for GeoDjango having custom_sql_for_model take the style object as a parameter allows for colorizing the generated spatial SQL -- the sqlcustom and syncdb commands are modified to pass in their style object to custom_sql_for_model.

Attachments (1)

gis_post_create_sql.diff (3.1 KB) - added by jbronn 6 years ago.
Modification of Django management commands to support GeoDjango

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by jbronn

Modification of Django management commands to support GeoDjango

comment:1 Changed 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [8133]) Fixed #7589 -- Added a way for post-table-creation SQL modifications to be done for custom fields (needed by geo-django, but useful in other situations, too).

Patch from Justin Bronn.

comment:2 Changed 6 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Since field classes aren't going to have their namespace populated by general user code, I removed the leading underscore from your method. It's now just post_create_sql(). I also made a slight tweak to the way you checked for fields declared directly on the object that looks equivalent to what you were attempting, but just double-check I haven't missed something.

comment:3 Changed 3 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.