I am saving the image to media folder and save the url in database.

photo_5 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True)

Then when the user clicks in trash can icon, i have an ajax request to 
delete the image from database. But there is the problem, i am not able to 
update the url in database or to delete. I already tried with update 
Listing.objects.all().filter(id = 1511).update(photo_5 
= None)

It seems that i can not change the value of photo_5.





quarta-feira, 16 de Outubro de 2019 às 15:23:07 UTC+1, Nuno Vieira escreveu:
>
> Hi there,
>
> i am creating a real estate app and i want users to insert and delete 
> images for the houses.
>
> It's all working great except the delete. 
>
> In my views.py i have the code: 
>
> listing = Listing.objects.get(id=1511)
>             if listing:
>                 listing.photo_5 = None
>                 listing.save(['photo_5'])
>                 return True
>
> photo_5 is an Imagefield and i want to change the value of that field in 
> database to None.
>
> Why is not changing? 
>
> Thanks for your help.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/70f0da13-24dd-4670-9fbf-e9cdf46bed34%40googlegroups.com.

Reply via email to