#32679: Django model not updating image field correctly (Raw content)
-------------------------------------+-------------------------------------
Reporter: mcardozo | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 3.1
layer (models, ORM) |
Severity: Normal | Keywords: models
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
My model:
{{{
class MyModel(models.Model):
picture = models.ImageField(blank=True, null=True,
upload_to='pictures')
}}}
Update a single object:
{{{
>>> picture
>>> <ContentFile: Raw content>
>>> mymodel = MyModel.objects.get(pk=instance.pk)
>>> mymodel.picture = picture
>>> mymodel.save()
>>> mymodel.picture
>>> <ImageFieldFile: pictures/fbdfe25b-b246-4f2d-9436-dca49aef88d7.png>
}}}
Good. Url result
`/media/pictures/fbdfe25b-b246-4f2d-9436-dca49aef88d7.png`.
Update a single object with the `update()` method:
{{{
>>> picture
>>> <ContentFile: Raw content>
>>> MyModel.objects.filter(pk=instance.pk).update(picture=picture)
>>> mymodel.picture
>>> <ImageFieldFile: Raw content>
}}}
Bad. Url result: `/media/Raw%20content`.
--
Ticket URL: <https://code.djangoproject.com/ticket/32679>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.100cedcc99f176f0b0f6f54ef155cbb2%40djangoproject.com.