I use jspdf to generate pdf for downloading by end users. I wish to
add a function to let them send an email to themselves through the
server.
Reading a little bit, I've seen a method to send the pdf to the server
as a base encoded string, and then have the server decode it, before
emailing the object. It seems to be bad practise and a convoluted way,
to me.

Anyway, the javascript is doing this:

    var pdf = doc.output();
    cliniclabel = $("#TopPatientBar").data("cliniclabel")
    patient_id = $('body').find("#PatientIP").html();
    $.ajax({
        method: "POST",
        url: 
`/clinic/${cliniclabel}/prescription/sendemail/patient/${patient_id}`,
        data: {data: pdf},
    }).done(function(data){
        console.log(data);
    });

And as a preliminary step, I'm trying to read the POST data:

        def SendPrescriptionbyMail(request, cliniclabel, patient_id):
        patient_id = int(patient_id)
        if request.method == 'POST':
            print("POST data", request.POST)
            cus = customer.objects.get(cstid = patient_id)
            recipient=cus.email

But I got this:
[14/Nov/2018 14:39:27] "GET
/appointments/static/appointments/js/popper.min.js.map HTTP/1.1" 404
1749
[14/Nov/2018 14:39:30] "GET /clinic/medicines HTTP/1.1" 200 8389
2018-11-14 14:39:36,360 django.security.RequestDataTooBig ERROR
Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.
2018-11-14 14:39:36,441 django.request WARNING  Bad Request:
/clinic/madhav/prescription/sendemail/patient/18
[14/Nov/2018 14:39:36] "POST
/clinic/madhav/prescription/sendemail/patient/18 HTTP/1.1" 400 17930

But rather than create an XY problem, can anyone tell me whether I'm
approaching this in the right way? Isnt base encoding a pdf object
from javascript for sending to django the wrong way to do this?

What would be the right way? Just point me along what I need to be looking at.

Sincerely yours,

Joel G Mathew

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA%3Diw_-5iVw_QnGy5hPft-%3DzAi8y5wkvuJ4QKAXRazhZaYgtjw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to