Re: working ImageField upload example

2016-08-25 Thread Greg Gilley
Switching back to 3.2 worked. That’s not a solution for when Django 1.10 comes out though. Thanks for your help! Greg > On Aug 24, 2016, at 7:47 PM, Andrew Backer wrote: > > Spoke too soon, this might be a known issue with how django + multiple > request-hungry middleware/apps. >

Re: working ImageField upload example

2016-08-24 Thread Andrew Backer
Spoke too soon, this might be a known issue with how django + multiple request-hungry middleware/apps. https://github.com/tomchristie/django-rest-framework/issues/3951 https://github.com/divio/django-cms/issues/5446 https://github.com/divio/django-cms/issues/5013 https://github.com/divio/django

Re: working ImageField upload example

2016-08-24 Thread Andrew Backer
Sorry, but not really. One small thing to try is changing `api/` in yours to `myapi/` just to see if they are doing their on processing based on the path. A quick look at their code and it seems alright. You might post an issue to their github and see if they respond. https://github.com/di

Re: working ImageField upload example

2016-08-24 Thread Greg Gilley
It appears to be a conflict with django cms. If I have this middleware installed, it fails. 'cms.middleware.toolbar.ToolbarMiddleware', Any ideas what is going on? Greg > On Aug 24, 2016, at 1:49 PM, Greg Gilley wrote: > > Okay, I created a small project and it works :-( > > Now to fi

Re: working ImageField upload example

2016-08-24 Thread Greg Gilley
Okay, I created a small project and it works :-( Now to figure out why it works and my larger project doesn’t… Greg > On Aug 24, 2016, at 10:49 AM, Andrew Backer wrote: > > Can you reproduce it in a small project, if you aren't willing to share the > one you have there? If you don't

Re: working ImageField upload example

2016-08-24 Thread Andrew Backer
Can you reproduce it in a small project, if you aren't willing to share the one you have there? If you don't necessarily need to have models, but it might be easier. Post to github/bitbucket or whatnot, or email it over to awbac...@gmail.com and I'll see if anything stads out. Also, try to

Re: working ImageField upload example

2016-08-24 Thread Greg Gilley
> On Aug 24, 2016, at 9:01 AM, Andrew Backer wrote: > > Try posting something like this for the image: > > SimpleUploadedFile(name="my-file.png", content=open(file_name).read()) The same pattern I’m using works fine for regular django forms, but I will try this (I’m open to anything at t

Re: working ImageField upload example

2016-08-24 Thread Andrew Backer
Try posting something like this for the image: SimpleUploadedFile(name="my-file.png", content=open(file_name).read()) * what does use_url do? never needed to use that, perhaps thats the issue * try not specifying the format=, if you are using SimpleUploadedFile Some other notes: Look at dj-in

Re: working ImageField upload example

2016-08-24 Thread Greg Gilley
Okay, knowing that its working for someone is helpful. It’s possible it’s a problem with my tests. I get errors back: response.data= {'name': ['This field is required.'], 'image': ['No file was submitted.'], 'recipe_as_image': ['No file was submitted.']} If I print out what the view is getting

Re: working ImageField upload example

2016-08-23 Thread Andrew Backer
Greg, Yes, file uploading doesn't work in JSON. It is theoretically possible, but don't try :D Multipart works fine here, and we have many several ViewSets and Views that receive images. We haven't even customized anything except by adding a function to de-nest the json values (e.g. user

Re: working ImageField upload example

2016-08-23 Thread Jeff Tchang
Here is what I have inside viewsets.py from rest_framework.parsers import MultiPartParser, FormParser, FileUploadParser class CustomMultiPartParser(MultiPartParser): media_type = 'multipart/*' class PictureViewSet(viewsets.ModelViewSet): queryset = Picture.objects.all().order_by('-crea

working ImageField upload example

2016-08-23 Thread ggilley
I'm ready to tear my hair out. I've been searching and searching for a working example of uploading to django using rest apis. I've looked at a lot of examples I've found searching, but none of them seem to work. Do multipart forms work in the current version? I never get any of the parameters