See the django docs for django.core.files.File
Where fd is an open file object:
model_instance.image_field.save('filename.jpeg', fd.read(), True)
More Related Contents:
- Django dynamic model fields
- Django set default form values
- Django FileField with upload_to determined at runtime
- How to create an object for a Django model with a many to many field?
- django abstract models versus regular inheritance
- Django post_save() signal implementation
- Getting TypeError: __init__() missing 1 required positional argument: ‘on_delete’ when trying to add parent table after child table with entries
- Get all related Django model objects
- difference between filter with multiple arguments and chain filter in django
- LEFT JOIN Django ORM
- Django Rest Framework and JSONField
- django.db.migrations.exceptions.InconsistentMigrationHistory
- Django Blob Model Field
- Django – How to rename a model field using South?
- Django Many-to-Many (m2m) Relation to same model
- Writing a __init__ function to be used in django model
- How to display uploaded images in “Change List” page in Django Admin?
- How to change the file name of an uploaded file in Django?
- Easiest way to rename a model using Django/South?
- models.py getting huge, what is the best way to break it up?
- Customize/remove Django select box blank option
- Duplicating model instances and their related objects in Django / Algorithm for recusrively duplicating an object
- one-to-many inline select with django admin
- How can I set a default value for a field in a Django model?
- Django filter JSONField list of dicts
- Django ModelForm to have a hidden input
- How to delete a record in Django models?
- Add custom form fields that are not part of the model (Django)
- Can a dictionary be passed to django models on create?
- Django cannot import name x [duplicate]