Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Problem with User Field #60

Closed
efeniks opened this issue Jun 17, 2015 · 0 comments
Closed

Problem with User Field #60

efeniks opened this issue Jun 17, 2015 · 0 comments

Comments

@efeniks
Copy link

efeniks commented Jun 17, 2015

Hello!

I have problem with uploads files. I add user field:

class Picture(models.Model):
user = models.ForeignKey(NormalUser)
file = models.ImageField(upload_to="pictures")

I found this solution for views.py in internet:

class PictureCreateView(CreateView):
model = Picture
fields = "all"

def form_valid(self, form):
    self.object = form.save(commit=False)
    self.object.user = self.request.user
    self.object.save()
    files = [serialize(self.object)]
    data = {'files': files}
    response = JSONResponse(data, mimetype=response_mimetype(self.request))
    response['Content-Disposition'] = 'inline; filename=files.json'

    return response

But when I add image i see this:

unt

Application don't upload file. Stop in 100%. What is the problem?

Thank You!
efeniks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants