0

I tried to apply a markdown plugin martor to my blog project which gives a nice toolbar in Django Admin.enter image description here Then I followed its instruction to apply the changes to my models.py and expected to see the same toolbar in my frontend blog post editor. However it doesn't work (it looks like this: enter image description here.

I also tried the suggestions in the post, still doesn't work.

Here is my code (model.py):

## models.py 

from django.db import models
from django.utils import timezone

from martor.models import MartorField

class Post(models.Model): 
    author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
    title = models.CharField(max_length=200)
    #text = models.TextField()
    text = MartorField()
    created_date = models.DateTimeField(
                   default=timezone.now)
    published_date = models.DateTimeField(
                    blank=True, null=True)

And forms.py

## forms.py
from django.forms import ModelForm

from martor.fields import MartorFormField
from martor.widgets import AdminMartorWidget

from .models import Post, Comment

class PostForm(ModelForm):

    class Meta:
        model = Post
        fields = ('title', 'text',)

How can I add the markdown toolbar as in Django Admin (the figure1) into my blog editing page? Thanks in advance!

skippyho
  • 149
  • 1
  • 9

2 Answers2

0

The answer given by the module author: https://github.com/agusmakmun/django-markdown-editor/issues/23

skippyho
  • 149
  • 1
  • 9
0

I had the same issue until I added them to my my template. skippyho provided a link, but here is the code:

  <link href="{% static 'plugins/css/ace.min.css' %}" type="text/css" media="all" rel="stylesheet" />
  <link href="{% static 'plugins/css/semantic.min.css' %}" type="text/css" media="all" rel="stylesheet" />
  <link href="{% static 'plugins/css/resizable.min.css' %}" type="text/css" media="all" rel="stylesheet" />
  <link href="{% static 'martor/css/martor.min.css' %}" type="text/css" media="all" rel="stylesheet" />

and

  <script type="text/javascript" src="{% static 'plugins/js/ace.js' %}"></script>
  <script type="text/javascript" src="{% static 'plugins/js/semantic.min.js' %}"></script>
  <script type="text/javascript" src="{% static 'plugins/js/mode-markdown.js' %}"></script>
  <script type="text/javascript" src="{% static 'plugins/js/ext-language_tools.js' %}"></script>
  <script type="text/javascript" src="{% static 'plugins/js/theme-github.js' %}"></script>
  <script type="text/javascript" src="{% static 'plugins/js/highlight.min.js' %}"></script>
  <script type="text/javascript" src="{% static 'plugins/js/resizable.min.js' %}"></script>
  <script type="text/javascript" src="{% static 'plugins/js/emojis.min.js' %}"></script>
  <script type="text/javascript" src="{% static 'martor/js/martor.min.js' %}"></script>
Marc LaBelle
  • 270
  • 5
  • 12