I successfully save if static path
How pass field image of customer to java
There many trial but src for field from model i cant save both i f i add url in style background not saved your text
type h
window.onload = function(){
//var dataImage = localStorage.getItem('imgData');
//var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
var imageObj = new Image();
var dataURL = canvas.toDataURL("image/png");
imageObj.onload = function(){
context.globalCompositeOperation="destination-over";
context.drawImage(imageObj,250, 50,700,400);// i edit it was context.drawImage(imageObj,50, 50);
context.font = "40pt Comic Sans MS";
context.fillText("draw here",20,80);
context.fill();
context.globalAlpha = 0.5;
};
//function getBase64Image(img) {
//var dataURL = canvas.toDataURL("image/png");
//return dataURL.replace(/^data:image/(png|jpg);base64,/, "");
//}
//here source imge for back ground if you want make it dynamic from upload by user use url of media <canvas style="background: url('{{ user.profile.profile_pic.url }}')" <canvas style="background: url({% static 'images/aes.png'%})"
imageObj.src = dataURL;//"data:image/png;base64," + dataImage;//'/media/imggg/gggg.png';//"{{ img }}"//'/media/imggg/gggg.png';
//cnanvas.innerHTML = `<img src="${url}" width="50%">`;//`media/${object.img.url}`//("<img src="{{ MEDIA_URL}}{{field.img.url}}">"); //<img src="{{ MEDIA_URL}}{{ City.image.url }}">"url '(${field.img.url})' ";//=("<img src='${{field.img.url}}'>");
};
ere
</main>
</body>
<script type="text/javascript">
</script>
</html>
Can pass variable from Django models and view to java
Ok any other help i needs
Edited code how make dynamic uploaded pic background drawing on it then save
2
Answers
def post(self, request,pk,*args, **kwargs,): json = { "error":True } form = LesionlocationForm(request.POST,request.FILES,initial= {'customer': "{{pk}}"})
class Lesionlocation(models.Model):
class LesionlocationView(View):
”’window.onload = function(){
var context = canvas.getContext("2d");
var imageObj = new Image();
var dataURL = canvas.toDataURL("image/png");
imageObj.onload = function(){
};
//here source imge for back ground if you want make it dynamic from upload by user use url of media background url(‘{{ field.photo.url }}’)"
imageObj.src = {{field.photo}};
}; ”’