pip install django-simplemde
INSTALLED_APPS = (
# ...
'simplemde',
# ...
)
from django.db import models
from simplemde.fields import SimpleMDEField
class Entry(models.Model):
title = models.CharField(max_length=250, verbose_name=u'Title')
content = SimpleMDEField(verbose_name=u'mardown content')
jQuery.ajax({
type: 'POST',
url: 'add_new_rec/'+prot_id+'/'+id_q+'/',
async: true,
cache: false,
processData: false,
contentType: false,
enctype: 'multipart/form-data',
data: {csrfmiddlewaretoken: getCookie('csrftoken'), 'r_text':text, 'file':my_file},
success: function (data) {
}
});
model.field = request.FILES['my_file']
model.save()