Skip to content

Conversation

@pizzapanther
Copy link

Added a simple place model. It is not a lot but gives a good start for users needing location based content.

Copy link
Member

Choose a reason for hiding this comment

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

should this be nullable too? It seems like the coordinate is the most important aspect, but from a practical workflow perspective, sometimes you may only have an address and you'd like to do the geolocation out-of-band, and making coordinate required limits how you can do that.

Copy link
Author

Choose a reason for hiding this comment

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

The one essential piece of info a place should have is that it is located somewhere. That is what my thought was. Also previously I've had problems with geospatial queries in Postgres when the fields are null. This may not be the case anymore, but I've always avoided nullable point fields since then especially since it is the most important field in the model.

Choose a reason for hiding this comment

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

I think having a required PointField on a Place is a fair requirement.

Copy link
Member

Choose a reason for hiding this comment

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

on a philosophical django tangent... we've had the idea of enforcing different levels of data validation. Like an unpublished article doesn't need a slug, but a published one does, so should the slugfield be required? As I typed that out... I think the answer is yes. before the save() hits, you should just pre-generate one, even if it's gibberish. Likewise here, we can assume the implementer has figured out how to get the latlong already, or decides to use a dummy latlong and then fills in the real one later (like how Google maps used to default to the geographic center of the continental US).

Copy link
Author

Choose a reason for hiding this comment

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

When I implemented the model on the front end I have a button that the user clicks to look up an address on google maps and fills in the coordinates. Originally, I wanted to include this functionality with the Armstrong contribution by using http://mapstraction.com/. Mapstraction would allow you to switch between map providers. However, I never got it to work right and had to finish with a quick implementation of just google maps in the client's code. Now that I have sometime, I could probably revisit it if you think it is appropriate to include with the contribution.

@tswicegood
Copy link

What about taking the model a step further and making relationships for State, City, and Zipcode so you can search for places within those, but also have relationships directly to those from other models?

@pizzapanther
Copy link
Author

Definitely a good idea and makes the model more robust. Is probably
overkill for most news orgs we've worked with, but with that said it should
be easy to implement. Also if you wanted to get advanced for your zip code
you could follow the model at the top of this page:
https://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/

Then you could do geospatial queries on zip codes too.

On Fri, Aug 24, 2012 at 9:34 AM, Travis Swicegood
[email protected]:

What about taking the model a step further and making relationships for
State, City, and Zipcode so you can search for places within those, but
also have relationships directly to those from other models?


Reply to this email directly or view it on GitHubhttps://github.com//pull/1#issuecomment-8003078.

Paul Bailey
Twitter: PizzaPanther
Phone: 409-233-3339

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.

3 participants