I'm currently making a blog app.
# models.py from django.db import models #Create your models here. class Post (models.Model): title = models.CharField (max_length = 100) body = models.TextField (null = True, blank = True) date = models.DateTimeField (auto_now_add = True) image = models.ImageField (null = True, blank = True, upload_to = "blog_pics") def __str __ (self): return self.title class Meta: ordering = ['-date']
MEDIA_ROOT = os.path.join (BASE_DIR,'media') MEDIA_URL ='/ media /'
I made some blog posts, but when I delete the posts on the admin site, they are deleted from the database, but not from the blog_pics directory of the media directory where the images are saved. After investigating various things, it was found that the database stores the path to save the image, and deleting the post does not delete the image itself.
When I delete a post from the Admin site, I want to delete the image at the same time. What should I do?
Answer # 1
When I looked it up, I found a package called django-cleanup.
- about image display of python
- about image output of python
- python - about mnist image display
- python - about the factor that the image quality of the jpeg file deteriorates
- python - about image display and position of main ()
- python - i want to change the ip address that the django app gets by default from remote_addr to http_x_forwarded_for in middlew
- python - error in image binarization using cv2adaptivethreshold function
- python - image display from the variable to which the file name is assigned
- python - i want to put the image file path in a variable and open it using that variable
- python - i want to know how to assign the image file name in the same directory to a variable and read the image from there
- python - when i tried to inflate the image, i couldn't read the image
- python - image cannot be read by opencv
- python 3x - about functions used in python for statement
- c # - about image display under timer monitoring on xamarin and ios
- python 3x - please teach about the exchange of information with qthead
- python - about x-axis adjustment in matplotlib
- python - about "" "of" "" select === = "" "
- python, about the fire spread step of forest fire simulation
- python - about hamiltonian neural networks
- python : Django Cookies Redirect.
- python : Django -Creating an presentation in the model
- python : How to solve decimal.invalidoperation on the server?
- python : Empty POST when using Telegram Webook
- python : Select data from Django database
- python : When using TENSORFLOW in Django, I want to make it possible to use the model that was built and loaded once while start
- python : How to access the session of a specific user?
- python : Django in Production (NGINX, GUNICORN, SUPERVISOR). Server Error (500) when sending a form
- python : How to edit a big table in Django template?
- python : How to shove all applications in one apps folder?