You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using this package in a Django 2.2 project, with a MySQL database (i.e., non-spatial).
I have a model containing a city field (actually a ForeignKey to a proper City model) and also a field for map coordinates for a marker. The location on a map itself is just for better understanding of where a point lies precisely in a city, asking the user to manually pin it with no need to query directions externally and make it all harder.
Therefore it would be really convenient for the users if the Django Admin site widget for PlainLocationField would respond to the value associated with the city as they fill in the publishing form. So that they're presented with their city map automatically when it's time to position their marker. I suppose that's where the based_fields argument could come in handy.
I'm using nominatim as a search provider and OpenStreetMap would be working just fine for my queries. I'm only looking up city names so it should be more than reliable. I won't be using Google both for privacy and budget concerns, so I'm not testing it at the moment.
Needless to say, OpenStreetMap can find anything I look up on their website so I suppose I would expect similar results with nominatim. However..
What happens is that the Admin site dynamically populates and re-render the map tiles (Mapbox tiles at the moment, and OpenStreetMap works too) as expected but it always picks a wrong place, in a different state, that has nothing to do with what I select in the form for my "city" field. It is usually a city in Germany or Australia but what I'm looking up is Spanish cities. So I guess the ForeignKey is to blame and something else other than the actual city name is being queried out.
Is there any way to make sure the widget is actually looking up the string I'm selecting? Or is there any way to use a foreign field for the argument based_fields?
Such as city.name (where city is a ForeignKey for a City model containg a CharField called name) like in class Place(models.Model):
--- city = models.ForeignKey(City, models.SET_NULL, blank=True, null=True)
--- position = PlainLocationField(based_fields=['city.name'],default='40.40513069752789,-3.71337890625')
Do you have any input on this matter?
The text was updated successfully, but these errors were encountered:
a-benkhaled
added a commit
to a-benkhaled/django-location-field
that referenced
this issue
Nov 25, 2021
I'm using this package in a Django 2.2 project, with a MySQL database (i.e., non-spatial).
I have a model containing a city field (actually a ForeignKey to a proper City model) and also a field for map coordinates for a marker. The location on a map itself is just for better understanding of where a point lies precisely in a city, asking the user to manually pin it with no need to query directions externally and make it all harder.
Therefore it would be really convenient for the users if the Django Admin site widget for PlainLocationField would respond to the value associated with the city as they fill in the publishing form. So that they're presented with their city map automatically when it's time to position their marker. I suppose that's where the based_fields argument could come in handy.
I'm using nominatim as a search provider and OpenStreetMap would be working just fine for my queries. I'm only looking up city names so it should be more than reliable. I won't be using Google both for privacy and budget concerns, so I'm not testing it at the moment.
Needless to say, OpenStreetMap can find anything I look up on their website so I suppose I would expect similar results with nominatim. However..
What happens is that the Admin site dynamically populates and re-render the map tiles (Mapbox tiles at the moment, and OpenStreetMap works too) as expected but it always picks a wrong place, in a different state, that has nothing to do with what I select in the form for my "city" field. It is usually a city in Germany or Australia but what I'm looking up is Spanish cities. So I guess the ForeignKey is to blame and something else other than the actual city name is being queried out.
Is there any way to make sure the widget is actually looking up the string I'm selecting? Or is there any way to use a foreign field for the argument based_fields?
Such as city.name (where city is a ForeignKey for a City model containg a CharField called name) like in
class Place(models.Model):
---
city = models.ForeignKey(City, models.SET_NULL, blank=True, null=True)
---
position = PlainLocationField(based_fields=['city.name'],default='40.40513069752789,-3.71337890625')
Do you have any input on this matter?
The text was updated successfully, but these errors were encountered: