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 883225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:33:10+00:00 2026-05-15T12:33:10+00:00

Greetings Having an ImageField object in my Foo model as such: class Foo(models.Model): name

  • 0

Greetings
Having an ImageField object in my Foo model as such:

class Foo(models.Model):
    name = models.CharField(max_length=50)
    photo = models.ImageField(upload_to='foobar', blank=True, null=True)

I want Foo to disable to delete the uploaded photo once a Foo object is deleted and a specific . How can I do this?

Ie:

If self.name == "foo":
    #skip deleting the image from the harddisk.
  • 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-15T12:33:10+00:00Added an answer on May 15, 2026 at 12:33 pm

    the best thing is to write a custom File Storage:

    http://docs.djangoproject.com/en/dev/howto/custom-file-storage/#howto-custom-file-storage

    override the delete method and set it the like described in

    http://docs.djangoproject.com/en/dev/topics/files/#the-built-in-filesystem-storage-class

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

Sidebar

Related Questions

I'm having trouble with my project. I have 2 models class UserPrefs(db.Model): user =
greetings all i have a domain class named car and i have an object
Greetings, Having a such select box: <select id=events> <option value=1 style=background-color:green;>Event 1</option> <option value=2
Greetings, I am having a lot of issues during implementation of a model driven
Greetings, The VBA code below will create an Excel QueryTable object and display it
Greetings, I have a particular object which can be constructed from a file, as
Greetings everyone. Having an issue compiling my script containing the following function. Three errors
Greetings. I'm having troubles with the following legacy code. It's fine in everything except
Greetings, I am having some issues with using a bool operation within a Where
Greetings All! I am having some troubles on how to execute thousands upon thousands

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.