I tried this, but it's just throwing an AttributeError ("can't set
sttribute"):

def create_a_company(name, logo_path):
    company = Company()
    company.name = name
    logo_url = image_url_from_path(logo_path)
    company.logo.url = logo_url
    company.save()


On Oct 2, 4:15 pm, akonsu <ako...@gmail.com> wrote:
> hello,
>
> try setting the logo.url property. i do it with FileFields all the
> time and it works.
>
> konstantin
>
> On Oct 2, 4:12 pm, ringemup <ringe...@gmail.com> wrote:
>
> > 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