Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion managing files, deleting file from file system with admin site
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sergey Seleznev  
View profile   Translate to Translated (View Original)
 More options Nov 15 2012, 7:55 pm
From: Sergey Seleznev <arto...@gmail.com>
Date: Thu, 15 Nov 2012 16:55:59 -0800 (PST)
Local: Thurs, Nov 15 2012 7:55 pm
Subject: Re: managing files, deleting file from file system with admin site

Thanks! Both methods are useful.

четверг, 15 ноября 2012 г., 18:02:02 UTC+4 пользователь lingrlongr написал:

> I've use something like this:

> class Car(models.Model):
>     #some fields
>     photo = models.ImageField(upload_to='cars')

>     def delete(self, *args, **kwargs):
>         storage, path = self.photo.storage, self.photo.path
>         super(Car, self).delete(*args, **kwargs)
>         storage.delete(path)

> On Thursday, November 15, 2012 12:48:16 AM UTC-5, Sergey Seleznev wrote:

>> Hi! I'm new to python and django(well, and web dev too).
>> I'm using python 2.7 and django 1.4
>> I went through the tutorial and then got issue with files managing.
>> I have model like this:

>> class Car(models.Model):
>>     #some fields
>>     photo = models.ImageField(upload_to='cars')

>> and media url/root configured in settings.py.
>> Also I have autogenerated django admin site.
>> Its works well and I can upload files to MEDIA_ROOT/cars/ automaticaly
>> when adding new object to Car model, but when I delete or change that
>> object from admin site old file doesnt deletes.
>> I need some easy and a good way to configure
>> model/admin_site/something_else to delete old files from file system when i
>> change/delete model object from admin site.
>> I think admin actions<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/actions/> can
>> be solution, but dont think it helps in case of changes and it cant help
>> override "Delete" button from object edit page.

>> Thanks for your help!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.