Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 535693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:44:37+00:00 2026-05-13T09:44:37+00:00

I am implementing an application with django, which has a model with a FileField:

  • 0

I am implementing an application with django, which has a model with a FileField:

class Slideshow(models.Model):
    name = models.CharField(max_length=30,unique=True)
    thumbnail = models.FileField(max_length=1000,upload_to="images/app/slideshows/thumbnails")

and I have an admin backend where django manages the models. I just added the file admin.py and django manages everything for me

from django.contrib import admin

from apps.gallery.models import Slideshow

admin.site.register(Slideshow)

In the backend, it is possible to add, delete and update the slideshows. However, when I try to update a slideshow and change its attribute thumbnail [FileField], django does not delete the old file. Consequently, after several updates the server is filled with many files which are useless.
My question is: how can I make django delete those files automatically after an update?

I would really appreciate your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:44:37+00:00Added an answer on May 13, 2026 at 9:44 am

    I’m sure Django does this by design. It can’t know, for example, whether any other models might be using that file. You would also be really surprised if you expected the file to remain and discovered that django deleted it!

    However, there’s also the issue that as soon as you change the file field, you lose the old file name.

    There’s an open ticket about that problem: http://code.djangoproject.com/ticket/11663

    There’s a patch in http://code.djangoproject.com/ticket/2983 which shows how to override __set__ to store the previous file name. Then your model’s __save__ method can get access to the previous file name to delete it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 304k
  • Answers 304k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm assuming that this is homework. How is the loop… May 13, 2026 at 8:48 pm
  • Editorial Team
    Editorial Team added an answer The copying and lack of "string literal optimization" is just… May 13, 2026 at 8:48 pm
  • Editorial Team
    Editorial Team added an answer Projecting onto an anonymous type (your second example) is the… May 13, 2026 at 8:48 pm

Related Questions

I am developing an issue tracking application in Django, mostly for a learning exercise
I am implementing a simple plugin architecture in an application. The plugin requirements are
I am implementing an asynchronous command pattern for the client class in a client/server
I am implementing Code Generation for WindowsForm control at Design-Time, using a Custom CodeDomSerializer.
I was wondering how you guys actually develop large applications when you are your

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.