Exemple #1
0
def create_doc(request):
    doc_api = documents()
    form = document_form(request.POST, request.FILES)
    try:
        response = {}
        if form.is_valid():
            r = {'name': form.cleaned_data["name"],
                 'description' : form.cleaned_data["description"],
                 'image' : request.FILES['image']}
            response = doc_api.add(r)
    except Exception as e:
        response = e
    return HttpResponse(str(response))
Exemple #2
0
def create_doc_form(request):
    form = document_form()
    t = loader.get_template("create_form.html")
    c = Context({'form':form})
    return HttpResponse(t.render(c))