Thanks. For a simpler case than what I'm dealing with, yes, that
would probably work.
On Oct 3, 2:21 pm, kmike wrote:
> If you have one default logo then maybe the 'right' way is to use
> 'default' parameter of ImageField?
>
> On 3 окт, 22:07, Nan wrote:
>
> > Nope, but I finally found what s
If you have one default logo then maybe the 'right' way is to use
'default' parameter of ImageField?
On 3 окт, 22:07, Nan wrote:
> Nope, but I finally found what seems to be the "right" way to do this
> (copies the file to the appropriate upload_to location, etc):
>
> from django.core.files.base
Nope, but I finally found what seems to be the "right" way to do this
(copies the file to the appropriate upload_to location, etc):
from django.core.files.base import File
def create_a_company(name, logo_path):
company = Company()
company.name = name
logo_file = open(logo_path)
c
did you try
company.logo = relative_path
?
On Oct 2, 4:45 pm, Nan wrote:
> OK, this seemed to work:
>
> def create_a_company(name, logo_path):
> company = Company()
> company.name = name
> relative_path = path_relative_to_media_root(logo_path)
> company.logo.name = relative_pat
OK, this seemed to work:
def create_a_company(name, logo_path):
company = Company()
company.name = name
relative_path = path_relative_to_media_root(logo_path)
company.logo.name = relative_path
company.save()
Thank you!
On Oct 2, 4:32 pm, Nan wrote:
> I tried this, but it'
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 wro
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 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 wi
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(model
Hello,
I'm trying to populate an ImageField with the content of an image from
it's url. I'm trying with the following code :
---
# image_uri is the URL of my image
# new_photo.photo is the ImageField field of my new_photo instance
current_file = File(urllib.urlopen(image_uri))
current_fi
9 matches
Mail list logo