Images disappear in Heroku after a while

Asked

Viewed 446 times

0

I made a website for a newspaper in Django. I have deployed to Heroku and there I have a news register, where I have the title, summary, content and date fields. According to the model:

class Noticia(models.Model):
    Titulo = models.TextField(max_length=255, null=False)
    Resumo = RichTextUploadingField(null=False)
    Conteudo = RichTextUploadingField(null=False)
    DataPublicacao = models.DateTimeField(auto_now_add=True)

However, when I register the images disappear after a while. HTML code

{% for noticia in noticias %}
        <div class="card">
            <div class="card-body d-flex flex-column align-items-start">
                <h3 class="mb-0">
                    <a class="text-dark" href="/posts/{{ noticia.pk }}">{{ noticia.Titulo|safe }}</a>
                </h3>
                <div class="mb-1 text-muted">{{ noticia.DataPublicacao|date:"d/m/y" }}</div>
                {{ noticia.Resumo|safe }}
            </div>
        </div>
{% endfor %}

The image is in the Summary field, the text I put together with it continues to appear, but the image does not. I’m using Heroku’s free plan, does anyone know what might be? What could be causing this?

1 answer

-1


Heroku, free or paid, does not have a permanent file system where you can store files and/or images permanently, as they explain themselves here. Heroku periodically goes through an internal routine that wipes out all the files that aren’t part of your code tracked by Git, and most likely because of that, you’re seeing your images get deleted after a while.

I recommend some storage service like AWS S3 or Google Cloud Storage to save your files.

Heroku’s own website has a official documentation how to implement in S3, but I will also leave a tutorial here which I consider more didactic (I used this to implement on my personal website).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.