Exemplo n.º 1
0
def addimage(request):
    error = None
    if request.method == 'POST':
        form = AddImageForm(request.POST.get("provider"), request.POST)
        if form.is_valid():
            img = form.cleaned_data['image']
            img.favorite = True
            img.save()
            favimage = {'name': img.name, 'image_id': img.image_id, 'id': img.id}
            return HttpResponse(json.dumps(favimage))
    else:
        form = AddImageForm(request.GET.get("provider"))
    return render_to_response('image_form.html', { 'form': form, 'error': error })
Exemplo n.º 2
0
def addimage(request):
    error = None
    if request.method == 'POST':
        form = AddImageForm(request.POST.get("provider"), request.POST)
        if form.is_valid():
            img = form.cleaned_data['image']
            img.favorite = True
            img.save()
            favimage = {
                'name': img.name,
                'image_id': img.image_id,
                'id': img.id
            }
            return HttpResponse(json.dumps(favimage))
    else:
        form = AddImageForm(request.GET.get("provider"))
    return render_to_response('image_form.html', {
        'form': form,
        'error': error
    })