-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PostalCode city FK #144
Comments
Can you give me an example of two cities with the same postal code? And assuming that's true, then yes, a M2M relationship would be a better fit. That's not difficult to code, but that would be...involved...to transition all of our users to. Is that something you could look into creating a PR for? |
I made inspection, and found cities which are present as separate instances in City model and have same postal_code.
But now I'm not sure about m2m. Yea, postal_code the same, but those What do you think about? |
I would rather have M2M models between the appropriate models than duplicate data. How far up the hierarchy do we need to switch to M2M (or, to ask it a different way: are those two cities in different Subregions or Regions? If we really wanted to go wild with it, we would basically model the entire hierarchy as a graph instead of a tree, and then model the entire history of all places (eg: cities in the Ottoman Empire or Austro-Hungary, Berlin belonging to both East and West Germany). All of that is possible, the real issue is the cities import command. That just gets more convoluted the more data model changes we make. 😖 |
m2m is not a silver bullet. I would say, best fit looks like this
class City(models.Model):
postal_codes = models.ManyToMany(Code, through=PostalCode) One more question/option. Do we have a polygons for region, subregion, city. We can use geometry instead of graph. Make sense? |
What data goes in the Right now we import points for cities, districts, and postal codes. Polygons exist. They are distributed in per-country zip files from Geonames, and we do nothing with them because they would presumably take forever to import and few users have requested them. There was an issue (#125) where somebody was going to add importing polygons. |
If we find a way to import polygons, we can use them to fill up any relations. Using polygons we can query all ps. Assuming that Point is in the middle of Polygon(Point if far enough of Polygon border), it should works even if geometry have not 100% accuracy. |
I suspect that would be incredibly slow but I'm willing to try it. Could you code up a PR that implements that? |
I'll start with polygon import. |
Hi,
Are you sure you FK is enough? For example in Germany, cities with same postal code, can exist.
I think 2m2 will be better fit.
Thanks.
https://github.com/coderholic/django-cities/blob/master/cities/models.py#L181
The text was updated successfully, but these errors were encountered: