[Django]-Django Markdown Editor does not show up

6๐Ÿ‘

In the videoโ€™s comments you can get the answer. Modify the next files:

models.py

from django_markdown.models import MarkdownField
...
body = MarkdownField()

settings.py

...
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")

# Markdown
MARKDOWN_EDITOR_SKIN = 'simple'

urls.py

...
from yourapp import settings
if settings.DEBUG:
    from django.conf.urls.static import static
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

In shell run:

python manage.py collectstatic
๐Ÿ‘คiago1460

1๐Ÿ‘

I have same problem. However, when I add Mr. iago1460โ€™s code without the urls.py part,after I run:

python manage.py collectstatic,

the django_markdown can work ,I use python 2.7 and django 1.8 version

the urls.py code here

from django.conf.urls import  include, url
from django.contrib import admin
#import settings

#if settings.DEBUG:
    #from django.conf.urls.static import static
    #urlpatterns += static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)

urlpatterns = [
    # Examples:
    # url(r'^$', 'cblog.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    url(r'^markdown/', include("django_markdown.urls")),
    url(r'^',include('blog.urls')),

]

here is my project files ,my project name is cblog ,app is blog:

djtest/cblog/cblog:

__init__.py  __init__.pyc  settings.py  settings.pyc  urls.py  urls.pyc  wsgi.py  wsgi.pyc

djtest/cblog:

 blog  cblog  db.sqlite3  manage.py  static
๐Ÿ‘คJoe Lin

1๐Ÿ‘

Yeah i found this problem too when i was trying qblog tutorial. iโ€™m using Python 3.4 and Django 1.8.1, But on the step to install markdown package, i decide to change the package into Django CKEditor.

Visit https://pypi.python.org/pypi/django-ckeditor to install.

After CKEditor has been installed properly, if you find the problem in import forms.util flattat when you are running the server.
Change your widgets.py under ckeditor folder (on windows environment the directory is under C:\Python34\Lib\site-packages\ckeditor), then change the line :

from django.forms.util import flatatt

to

from django.forms.utils import flatatt

Follow in how to use CKEditor then implement it on your qblog.
The result will be like this :

enter image description here

๐Ÿ‘คFatkhan Fauzi

1๐Ÿ‘

Try this easier way:

in admin.py :

from django_markdown.admin import MarkdownModelAdmin
from django_markdown.widgets import AdminMarkdownWidget
from django.db.models import TextField


class EntryAdmin(MarkdownModelAdmin):
    ... #your_code
    formfield_overrides = {TextField: {'widget': AdminMarkdownWidget}}

admin.site.register(models.Entry, EntryAdmin)
๐Ÿ‘คAditya

0๐Ÿ‘

This happens when you are using python 2x
Now,what happens is that the stylesheets and javascript are not loaded

So what you can do is:

from django_markdown.widgets import AdminMarkdownWidget
  from django.db.models import TextField

  class EntryAdmin(MarkdownModelAdmin):
      list_display = ("title", "created")
      prepopulated_fields = {"slug": ("title",)}
      # Next line is a workaround for Python 2.x
      formfield_overrides = {TextField: {'widget': AdminMarkdownWidget}}

and this will work!!!!!!!!!!!!!

๐Ÿ‘คHiro

0๐Ÿ‘

Python 2.x You need add that:

formfield_overrides = {TextField: {โ€˜widgetโ€™: AdminMarkdownWidget}}

๐Ÿ‘คEds_k

Leave a comment