Skip to content
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

DjangoGooglePointFieldWidget is not defined #26

Closed
gabrielpiccolo4 opened this issue Jun 9, 2017 · 8 comments
Closed

DjangoGooglePointFieldWidget is not defined #26

gabrielpiccolo4 opened this issue Jun 9, 2017 · 8 comments

Comments

@gabrielpiccolo4
Copy link

gabrielpiccolo4 commented Jun 9, 2017

Guys, sorry to trouble you but I've followed the instructions in the docs and when my browser renders the page the debugger says 'ReferenceError: DjangoGooglePointFieldWidget is not defined' in the following line: new DjangoGooglePointFieldWidget(mapWidgetOptions);.

My template already has jQuery and Bootstrap setted, and inside Django settings the app 'mapwidgets', is placed, I don't know if this is an issue? The following image shows how the page is displayed:
image

@erdem
Copy link
Owner

erdem commented Jun 11, 2017

Hi @gabrielpiccolo4

It seems the static files not loaded in your project. Did you call python manage.py collectstatic?

You must copy the third-party packages static files into the STATIC_ROOT with collectstatic management command.

@gabrielpiccolo4
Copy link
Author

gabrielpiccolo4 commented Jun 11, 2017

Hey @erdem thanks for answering back!

Sorry I missed this part of the tutorial. I ran the command collectstatic and Django successfuly coppied all the files, but the browsers yet say Reference Error.

The strange thing is that when I create the field with GoogleStaticMapWidget it loads the image <img src="/static/mapwidgets/images/no-map-image.png" class="no-map-image"> from the static folder. Also, all the js files are inside the static folder.

*The template has the tag {% load staticfiles %}

@erdem
Copy link
Owner

erdem commented Jun 12, 2017

That image is a placeholder image for blank geo point fields. There is no input option for GoogleStaticMapWidget. The static widgets are read-only. If you need to input for geo point fields, you have to use GooglePointFieldWidget.

The static files issue must be fixed after the collectstatic command. If it is not sorted out, post your Django static app configuration in the project settings file.

Thanks

@erdem erdem closed this as completed Jun 13, 2017
@gabrielpiccolo4
Copy link
Author

gabrielpiccolo4 commented Jun 13, 2017

Hi @erdem, I tried many things and none worked... I also created a new app (Django 1.11) to test and the problem persists (django_1-11_maps-widget.zip). Maybe you can help me, my settings.py related to static-files are as follows:

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]

I'm just wondering, (please notice I'm a student studying the framework) the collectstatic isn't used just when the app is ready to deploy? 'Cause I'm yet using django's run server to test it.

Just a question, I'm not using PostgreSQL, I'm using MySQL, and my models ain't using the PointField, but CharFields (both for coordinates and city name), not sure if this can cause that error?

Thanks,
Gabriel

@erdem
Copy link
Owner

erdem commented Jun 15, 2017

Hi @gabrielpiccolo4

I didn't try the widget with CharField, but it should work.

If you are working on the development mode, you must add static files serving view for the urls. I think you missed that part in your project.

Check out the links below:

https://docs.djangoproject.com/en/1.11/howto/static-files/#serving-static-files-during-development

https://github.com/erdem/django-map-widgets/blob/master/example/example/urls.py#L13

Thanks.

@gabrielpiccolo4
Copy link
Author

I missed this part in this new project I created, unfortunately no luck =(
Maybe is it something in my Windows? Could you try to run python manage.py runserver on the project below? The index page is using the widget.

django_1-11_maps-widget2.zip

Thanks Erdem, again, sorry to trouble you

@erdem
Copy link
Owner

erdem commented Jun 16, 2017

I understand the issue. Your template doesn't have {{ form.media }} variable. Put {{ form.media }} variable to <head> tag or end of the <body> tag in your index.html. Then it should work.

Like here:
https://github.com/erdem/django-map-widgets/blob/master/example/templates/cities/form.html#L4

I missed this part when I was writing instructions. I will update the document soon.

Thank you for noticing me about that.

@gabrielpiccolo4
Copy link
Author

It worked! Thanks @erdem!

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

No branches or pull requests

2 participants