File "<string>", line 1, in <module>
File
"/Users/andrewfam/.virtualenvs/oshop/lib/python2.7/site-packages/django/db/models/manager.py",
line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File
"/Users/andrewfam/.virtualenvs/oshop/lib/python2.7/site-packages/django/db/models/query.py",
line 346, in create
obj = self.model(**kwargs)
File
"/Users/andrewfam/.virtualenvs/oshop/lib/python2.7/site-packages/django/db/models/base.py",
line 470, in __init__
setattr(self, field.attname, val)
File
"/Users/andrewfam/.virtualenvs/oshop/lib/python2.7/site-packages/django/db/models/fields/subclassing.py",
line 44, in __set__
obj.__dict__[self.field.name] = self.field.to_python(value)
File
"/Users/andrewfam/.virtualenvs/oshop/lib/python2.7/site-packages/filebrowser_safe/fields.py",
line 106, in to_python
return FileObject(url_to_path(value))
File
"/Users/andrewfam/.virtualenvs/oshop/lib/python2.7/site-packages/filebrowser_safe/functions.py",
line 59, in url_to_path
value = mediaurl_re.sub('', value)
TypeError: expected string or buffer
On Friday, June 5, 2015 at 9:20:15 AM UTC+8, Sam Kingston wrote:
>
> Do you have a full trace back though? Without it, it is hard to see what
> the exception is referring to
> On 5 Jun 2015 10:49 am, "Andrew Fam" <[email protected] <javascript:>>
> wrote:
>
>> upload_receive(request) gives <InMemoryUploadedFile: bg.png (image/png)>
>>
>>
>> f = File(upload_receive(request).open())
>> returns <File: None>
>> ProductImage.objects.create(file=f, product_id=2) just creates a
>> ProductImage with blank file and description
>>
>> f = File(upload_receive(request))
>> returns <File: bg.png>
>> ProductImage.objects.create(file=f, product_id=2)
>> returns
>> *** TypeError: expected string or buffer
>>
>>
>>
>> On Friday, June 5, 2015 at 8:38:38 AM UTC+8, Sam Kingston wrote:
>>>
>>> Can you paste in the full exception?
>>> On 5 Jun 2015 10:36 am, "Andrew Fam" <[email protected]> wrote:
>>>
>>>> Hey Sam,
>>>>
>>>> the gist doesn't work. Still getting the same error
>>>>
>>>> product.images.create(file=File(f), product_id = product.id)
>>>>
>>>> On Friday, June 5, 2015 at 6:56:47 AM UTC+8, Sam Kingston wrote:
>>>>>
>>>>> Hi Andrew,
>>>>>
>>>>> Try something like this (ripped from a shop I have written that syncs
>>>>> images from another database):
>>>>>
>>>>> https://gist.github.com/sjkingo/b836272f0757b20f8016
>>>>>
>>>>> Hope this helps
>>>>>
>>>>> On Thursday, 4 June 2015 19:42:09 UTC+10, Andrew Fam wrote:
>>>>>>
>>>>>> I"m wondering how to create a new product image directly without the
>>>>>> admin.
>>>>>>
>>>>>> Using a package that defines the following
>>>>>>
>>>>>> def upload_receive( request ): """ Returns the file(s) uploaded by
>>>>>> the user. """ return request.FILES['files[]'] if request.FILES else
>>>>>> None
>>>>>> I tried to create a Product image with the following which works in
>>>>>> non cartridge fields,
>>>>>>
>>>>>> f = upload_receive(request)
>>>>>> instance = ProductImage.objects.create(file=f, product_id=2)
>>>>>>
>>>>>> I get *** TypeError: expected string or buffer
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "Mezzanine Users" group.
>>>> To unsubscribe from this topic, visit
>>>> https://groups.google.com/d/topic/mezzanine-users/tGaQWvZb4eg/unsubscribe
>>>> .
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Mezzanine Users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/mezzanine-users/tGaQWvZb4eg/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.