How to use post_save signal ?
Hi all
I am using Django-1.2.5 and i want to use post_save signal in the following problem/task.
I have :-
models.py
image = models.ImageField(.....)
remove_image = models.BooleanField()
Now i want :-
1) When the user uploads the file , the file path appears on the imageField like this.
Currently: images/testimonial-bottom_1.png
Change:
I want to give the option to delete the file .So i made a field called remove image which is a checkbox . Now when the user clicks that remove_image checkbox and press save the image should get deleted. I was going through the documentation and believe that this problem could be solved by using post_save signal
I have not used signals so need help ,
def delete_old_image(sender, instance, using=None,*args, **kwargs):
try:
old_record = sender.objects.get(pk=instance.pk)
old_record.delete()
except sender.DoesNotExist:
pass
signals.post_save.connect(delete_old_image, sender=Trip)
How can i achieve this task by using signals or without signals.
Any help will be appreciated.
--
Regards
Nikhil Verma
+91-958-273-3156
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home