Try to override `delete` method in your model. You should do something like
this:

class Example(models.Model):
    f = models.FileField(null=True, blank =True)


    def delete(self,*args,**kwargs):
        if os.path.isfile(self.f.path):
            os.remove(self.f.path)

        super(Example, self).delete(*args,**kwargs)


2016-07-09 21:04 GMT+05:00 <sevenrrain...@gmail.com>:

> This way the Image is removed from database, not from the server.
>
> On Friday, July 8, 2016 at 6:41:57 PM UTC+3, Mstislav Kazakov wrote:
>>
>> Just pass empty value in file field.
>> If blank=True and null=True, everything should work fine and image will
>> be removed.
>>
>> пятница, 8 июля 2016 г., 17:23:42 UTC+5 пользователь sevenr...@gmail.com
>> написал:
>>>
>>> The user has the possibility to add/delete image and documents.
>>>
>>>
>>> I used GCBV UpdateView and a FormModel for this.
>>>
>>>
>>> How can I offer the possibility to the user to delete the file/image ?
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bdd2edd2-d232-416e-9ff4-b5b3519e6c1e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/bdd2edd2-d232-416e-9ff4-b5b3519e6c1e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP8J_KZQrXuvmaqVyGomh-OjeJotKQasWJf5%3D%3Dqx8sGDZgadmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to