Closed jeverling closed 3 years ago
Hi jeverling! Great to hear that it worked for you.
Wondering if you'll be able to help me. In my forms.py, I get a "NameError: name 'City' is not defined". I believe it's to do with the fact that I haven't imported the City model from anywhere into the forms.py yet. Wonder if you can help.
Thanks a lot :)
Hi Andrew, do you have a City
model defined in jobber/models.py
?!
If yes, I think you just have to add , City
to this line:
from .models import Job, User, Category, Application, Jobber
Or did you copy coordinates
and city_hall
from the README? Those are just examples, you have to replace e.g. coordinates
with your own django.contrib.gis.db.models.PointField
instance. The demo project should help you to figure out how: https://github.com/erdem/django-map-widgets/blob/master/demo/
The demo project has a separate app for "cities" (and it's using a different PointField and not coordinates
) as you can see here: https://github.com/erdem/django-map-widgets/blob/master/demo/cities/models.py#L30
Hope you get it working.
Thanks for the swift reply!
Am sure glad you pointed out the demo, I jumped straight into the documentation and didn't notice it.
Btw, would we need to use PostgreSQL instead of the standard SQLite as the default database for our django project instead? (I noticed the demo provided used PostgreSQL instead of my SQLite.) Thus subsequently installing PostGIS and all its dependencies as guided here??
Also, mind sharing what django version you're used this on? Just hoping that this package still works on django 3.1.4.
Yes, you actually need PostGIS (vanilla PostgreSQL is not enough). I just run a Docker container like this:
docker run --name postgis_db -e POSTGRES_PASSWORD=your_password -e POSTGRES_DB=your_db -v /opt/docker/volumes/some_volume_name/data:/var/lib/postgresql/data -p 5432:5432 -d postgis/postgis
Due to the port forwarding, you can then just use localhost
as HOST
.
This is my django version: Django==3.1.4
Also don't forget that you need to install psycopg2-binary
Python package for PostgreSQL.
@jeverling Thank you for your contributions!
When I was documenting this package usage in the first place, Google Map APIs configuration page was so different. I saw the entire page has changed after reading your message. Also, as far as I remember only Google Map JS API activation was enough to use the widget. However, I have added new Google APIs configuration
sections to each widget documents. Also, this issue gave me a chance to test map widgets on Django 3.1, they work fine.
https://django-map-widgets.readthedocs.io/en/latest/widgets/point_field_map_widgets.html
It took me a bit to figure out that I had to enable the Places API. It's obvious in hindsight, but it might be helpful to others to list all Google APIs that this package uses.
And thank you very much for this project, it is a great time-saver!