Say I have an image file on disk and a model that uses an ImageField.
If I want to create a model instance with that image file in the image
field without explicitly running through a form and a POST operation,
how could that be done?

Example of what I'm trying to accomplish:

class Company(models.Model):
    name = models.CharField(max_length=50)
    logo = models.ImageField()


def create_a_company(name, logo_path):
    company = Company()
    company.name = name
    logo_file = # DO SOMETHING HERE
    company.logo = logo_file
    company.save()

--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to