We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class PictureCreateView(CreateView): model = Media fields = "all"
def form_valid(self, form): self.object = form.save() files = [serialize(self.object)] data = {'files': files} print self.request response = JSONResponse(data, mimetype=response_mimetype(self.request)) response['Content-Disposition'] = 'inline; filename=files.json' return response def form_invalid(self, form): data = json.dumps(form.errors) return HttpResponse(content=data, status=400, content_type='application/json')
sismilar to
def PictureCreateView(request): if request.is_ajax() or request.method=='POST': frm_media = FormMedia(data=request.POST or None, ) if frm_media.is_valid(): object = frm_media.save() files = [serialize(object)] data = {'files': files} response = JSONResponse(data, mimetype=response_mimetype(request)) response['Content-Disposition'] = 'inline; filename=files.json' return HttpResponse(response) else: data = json.dumps(frm_media.errors) return HttpResponse(content=data, status=400, content_type='application/json') else: frm_media = FormMedia() return
class FormMedia(ModelForm): model = Media fields = "all"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
class PictureCreateView(CreateView):
model = Media
fields = "all"
sismilar to
def PictureCreateView(request):
if request.is_ajax() or request.method=='POST':
frm_media = FormMedia(data=request.POST or None, )
if frm_media.is_valid():
object = frm_media.save()
files = [serialize(object)]
data = {'files': files}
response = JSONResponse(data, mimetype=response_mimetype(request))
response['Content-Disposition'] = 'inline; filename=files.json'
return HttpResponse(response)
else:
data = json.dumps(frm_media.errors)
return HttpResponse(content=data, status=400, content_type='application/json')
else:
frm_media = FormMedia()
return
in forms.py
class FormMedia(ModelForm):
model = Media
fields = "all"
The text was updated successfully, but these errors were encountered: