Django leaflet marker icon doesn't appear on Heroku

207 Views Asked by At

I have deployed my Django app to Heroku but when I want to fill the location field, the marker icon doesn't appear even though I have used whitenoise to serve the static files. It is working locally though. This is the image

Here's how I set my whitenoise

INSTALLED_APPS = [
    ...,
    'whitenoise.runserver_nostatic'
]

MIDDLEWARE = [
    ...,
    'whitenoise.middleware.WhiteNoiseMiddleware'
]

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR,'static')

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

MEDIA_ROOT = os.path.join(BASE_DIR,'media')

MEDIA_URL = '/media/'

Note:

The circle marker works fine

2

There are 2 best solutions below

5
Swift On

Have you been through this section of the django heroku tutorials?

https://devcenter.heroku.com/articles/django-app-configuration

You need to specify certain files so that heroku automatically tried to collectstatic files

0
Sanchouz On

I had the same issue, except I deployed on DigitalOcean. I couldn't find any info on that matter, so I came up quick and dirty solution: I just created those images, that Leaflet was trying to get (see screenshot below).

I know, that it's not a good solution, but I just needed some quick fix, so I'm OK with that. I also noticed, that in my dev env (which is Windows, btw), not only everything worked, but python manage.py collectstatic collected much more leaflets' images, than it did in my prod env (which is Ubuntu). I'm using the same versions of django-leaflet (0.29.0) and in the same virtual env (conda with Python3.9). Very strange.

creating images