makinacorpus / django-leaflet

Use Leaflet in your Django projects
GNU Lesser General Public License v3.0
716 stars 282 forks source link

Installation error? #240

Open stolken opened 6 years ago

stolken commented 6 years ago

I followed the short tutorial to install django-leaflet: pip install django-leaflet Added leaflet to my INSTALLED_APPS in the file /opt/bitnami/apps/django/django_projects/Project/Project/settings.py

The map won't show because the leaflet files cannot be found:

GET http://35.192.82.255/Project/static/leaflet/leaflet.extras.js net::ERR_ABORTED 404 (Not Found)
35.192.82.255/:7 GET http://35.192.82.255/Project/static/leaflet/leaflet.js net::ERR_ABORTED 404 (Not Found)
(index):15 GET http://35.192.82.255/Project/static/leaflet/leaflet.css net::ERR_ABORTED 404 (Not Found)
(index):11 GET http://35.192.82.255/Project/static/leaflet/leaflet.extras.js net::ERR_ABORTED 404 (Not Found)
(index):12 Uncaught ReferenceError: L is not defined
    at (index):12
(anonymous) @ (index):12
(index):15 GET http://35.192.82.255/Project/static/leaflet/leaflet.css net::ERR_ABORTED 404 (Not Found)
(index):28 Uncaught ReferenceError: L is not defined
    at loadmap ((index):28)

I do not see a 'static' directory in /opt/bitnami/apps/django/django_projects/Project/Project/

Am I supposed to create it?

A search for leaflet:

vm:/opt/bitnami/apps/django/django_projects/Project/Project$ sudo find / -name "leaflet" -print
/opt/bitnami/apache2/var/cache/mod_pagespeed/v3/35.192.82.255/http,3A/,2F35.192.82.255/Project/static/leaflet
/opt/bitnami/python/lib/python3.6/site-packages/leaflet
/opt/bitnami/python/lib/python3.6/site-packages/leaflet/templates/leaflet
/opt/bitnami/python/lib/python3.6/site-packages/leaflet/static/leaflet
/opt/bitnami/python/lib/python3.6/site-packages/leaflet/static/leaflet/leaflet
anou commented 4 years ago

Any updates on this? I face the same problem... Thx

Gagaro commented 4 years ago

Are your other statics available? Is your static files configuration correctly set (https://docs.djangoproject.com/en/3.0/howto/static-files/)?

anou commented 4 years ago

Yes all my other statics are available. It is on the staging server that I see in the console :

Capture d’écran 2020-05-25 à 02 43 18

it is searching for some js file here : app/static/leaflet

Fixed with this in Dockerfile : && ln -sf /usr/local/lib/python3.7/site-packages/leaflet/static/leaflet /usr/src/app/static/leaflet

Gagaro commented 4 years ago

Did you do a collectstatic after adding django-leaflet?

anou commented 4 years ago

Nope. Nothing like this. Worked like a charm with the basic on local environment but didn't go likely on staging.

renkh commented 3 years ago

You gotta run python manage.py collectstatic to copy all the static files into your STATIC_ROOT directory that you specified in settings.py. And then configure your web server to serve the files in STATIC_ROOT. Read more about deploying static files https://docs.djangoproject.com/en/3.0/howto/static-files/deployment/#serving-static-files-from-a-dedicated-server.