Menerima Jasa Pembuatan Website Django & Wordpress (klik disini)

Django markdownx is a Markdown editor built for Django

Django markdownx

Previously i already created isssue before:, as the owner says:

There is no easy way to do it “quick”, I think. You could change JS script a bit to be able to send images. This should be a simple change.

And finally i got it with custome simple javascript code inside file of dummy.html

<script src="/static/suit/js/jquery-1.8.3.min.js"></script>

<form enctype="multipart/form-data" method="POST" action=".">{% csrf_token %}
  {{ form.image }}

    // CSRF code
    function getCookie(name) {
        var cookieValue = null;
        var i = 0;
        if (document.cookie && document.cookie !== '') {
            var cookies = document.cookie.split(';');
            for (i; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) === (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
        return cookieValue;

    // Uploading the image if on change.
    $('input[name=image]').on('change', function(evt) {
      var formData = new FormData($('form').get(0));
      formData.append("csrfmiddlewaretoken", getCookie('csrftoken'));

          url: '/markdownx/upload/',
          type: 'POST',
          data: formData,
          async: true,
          cache: false,
          contentType: false,
          enctype: 'multipart/form-data',
          processData: false,
          beforeSend: function() {
          success: function (response) {
          error: function(response) {
              console.log("error", response);
      return false;

Hope it usefull..

javascript django templates ajax module tricks solution problem

Your Answer

blog comments powered by Disqus