0

With Heroku's ephemeral filesystem, it's obvious we can't host user-uploaded images or dynamically changing ones in the app's filesystem because these won't be available to other dynos.

However, I'm looking for a solution to store a SINGLE image, used as sort of a logo, in a Django URLField() - this image's URL will be sort of a fallback if an image at a remote location (external service) is not available( Hence the URLField and not ImageField)

picture_url = models.URLField(null=True)

For me, setting-up and using services like Amazon S3 seems like an overkill. Using services like imgur/Photobucket seems unreliable.

Any workarounds?

zerohedge
  • 3,185
  • 4
  • 28
  • 63

1 Answers1

1

Sadly, no.

There's no functional difference between storing a single image, or multiple images. The issue is that Heroku deploys a snapshot of your code, as represented in Git. If an asset doesn't live in your repository, it will be throw away whenever Heroku re-deploys your code (including when you push new code).

An image hosting service (storing the URL as you're already planning to do) is your best bet.

Jack Shedd
  • 3,501
  • 20
  • 27
  • Thanks for the answer. "If an asset doesn't live in your repository, it will be throw away whenever Heroku re-deploys your code" - the image does "technically" live in my git repository though... – zerohedge Aug 09 '18 at 05:36
  • What do you mean by technically? If the image exists in the repo, make sure it's in the STATIC_DIR, and set your URL field to the URL for the image within your application. – Jack Shedd Aug 09 '18 at 05:43
  • I mean literally. Sorry. I tried this but got the following error: "Missing staticfiles manifest entry for 'sass/img/no_pic_dashboard.jpg'" – zerohedge Aug 09 '18 at 05:45
  • Have you run collectstatic? – Jack Shedd Aug 09 '18 at 15:09
  • Yes. The app even ran fine for hours before crashing. If the manifest was missing from the get-go Whitenoise would have crashed on deployment. – zerohedge Aug 09 '18 at 15:10
  • I believe this thread would be related to your issue: https://stackoverflow.com/questions/44160666/valueerror-missing-staticfiles-manifest-entry-for-favicon-ico – Jack Shedd Aug 10 '18 at 00:50
  • Thanks. But these refer to problems when running in development environment, my issue is the opposite: site runs fine in development, but crashes on Heroku production(despite building successfully on deployment). – zerohedge Aug 10 '18 at 09:20