On donderdag 21 juni 2018 11:31:26 CEST prateek gupta wrote: > Thanks for reviewing the code. > > I am new to Django and just tried to put logic from googling to achieve my > goal. > That's why I don't understand my code completely.
Try to understand it before applying. The main issue you're facing is the difference between class attributes and model fields. A model field is a special class attribute that Django stores in the database. You have to declare them using one of the field types[1] that Django supports. Everything else is not saved in the database. You're using a custom model field[2] for the location in your model. Part of that field is that it stores in the lon/lat information for you, so that you don't have to worry about it. What it doesn't provide is a solid way for you to get the location data from the field. As you've figured out, it is stored as a string, which makes it difficult to make queries on lon/ lat coordinates. So it's probably not the right tool for the job. But before you go looking for a different package, you should really learn more about Django, for example complete the tutorial and in your case it'll be helpful to go through the GIS tutorial[3] as well. Cause then you'd discover that other then support for Mapbox and Google maps, Django already has built in most of what the DJango Location Field package is offering you. -- Melvyn Sopacua -------- [1] https://docs.djangoproject.com/en/2.0/ref/models/fields/ [2] https://docs.djangoproject.com/en/2.0/howto/custom-model-fields/ [3] https://docs.djangoproject.com/en/2.0/ref/contrib/gis/tutorial/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4665207.94lpJElZK9%40fritzbook. For more options, visit https://groups.google.com/d/optout.