Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo application - martor_demo not working! #95

Closed
alfarhanzahedi opened this issue Nov 15, 2019 · 5 comments
Closed

Demo application - martor_demo not working! #95

alfarhanzahedi opened this issue Nov 15, 2019 · 5 comments

Comments

@alfarhanzahedi
Copy link

Here's the complete trace on running the command python manage.py check:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/Django-3.0b1-py3.7.egg/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/Django-3.0b1-py3.7.egg/django/core/management/__init__.py", line 377, in execute
    django.setup()
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/Django-3.0b1-py3.7.egg/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/Django-3.0b1-py3.7.egg/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/Django-3.0b1-py3.7.egg/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/martor-1.4.4-py3.7.egg/martor/models.py", line 3, in <module>
    from .fields import MartorFormField
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/martor-1.4.4-py3.7.egg/martor/fields.py", line 4, in <module>
    from .widgets import (MartorWidget, AdminMartorWidget)
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/martor-1.4.4-py3.7.egg/martor/widgets.py", line 14, in <module>
    class MartorWidget(forms.Textarea):
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/martor-1.4.4-py3.7.egg/martor/widgets.py", line 51, in MartorWidget
    class Media:
  File "/home/alfarhanzahedi/Projects/django/django-markdown-editor/venv/lib/python3.7/site-packages/martor-1.4.4-py3.7.egg/martor/widgets.py", line 73, in Media
    if MARTOR_ENABLE_CONFIGS['spellcheck'] == 'true':
KeyError: 'spellcheck'
@0p3r4t0r
Copy link
Contributor

0p3r4t0r commented Nov 26, 2019

The Problem

When trying to run the Martor demo application by following the instructions in README.md. The step where you are supposed to run

python manage.py makemigrations && python manage.py migrate

results in a stack trace like the one above.

This is because the spellcheck key is not present in the MARTOR_ENABLE_CONFIGS dictionary in the filemartor_demo/martor_demo/settings.py

Currently the dictionary looks like this.

MARTOR_ENABLE_CONFIGS = {
    'imgur': 'true',     # to enable/disable imgur/custom uploader.
    'mention': 'true',   # to enable/disable mention
    'jquery': 'true',    # to include/revoke jquery (require for admin default django)
    'living': 'false'    # to enable/disable live updates in preview
 }

The Solution

Open the file martor_demo/martor_demo/settings.py and add the missing key.

MARTOR_ENABLE_CONFIGS = {
    'imgur': 'true',         # to enable/disable imgur/custom uploader.
    'mention': 'true',       # to enable/disable mention
    'jquery': 'true',        # to include/revoke jquery (require for admin default django)
    'living': 'false',       # to enable/disable live updates in preview
    'spellcheck': 'true',    # to enable/disable spellcheck in the editor
 }

Then try running

python manage.py makemigrations && python manage.py migrate

This solved the issue for me, but there were still some other problems. (See my next post below)

Pull Request

I have added a pull request for this change. It has been a while since I have made a pull request. Let me know if there are any conventions or etiquette I ought to adhere to.

#98

@0p3r4t0r
Copy link
Contributor

0p3r4t0r commented Nov 26, 2019

Additional Problems and Solutions

Staticfiles

In the template django-markdown-editor/martor_demo/app/templates/base.html there is a line that says {% load staticfiles %} .

Solution

Change the line that line to {% load static %}.

Preview is not working

  • Text from the editor is not rendered in the preview.
  • test_markdownify is not working either.

Solution

The culprit is in the file django-markdown-editor/martor/emoji.py. The fifth line of that file needs to be changed to from django.templatetags import static

For reference, see lines 14 and 15 of the relevant Django 3 source code file.

Keep in mind that after making this change, you will need to reinstall the package. This can be done by running python setup.py install again from the project's root directory.

This was referenced Nov 26, 2019
@alfarhanzahedi
Copy link
Author

I ended up using django-mdeditor (https://github.com/pylixm/django-mdeditor). Nevertheless, I will try this locally and let you know :)

Thanks for your help!

@BenjaminPalko
Copy link
Contributor

Ive put out a PR that fixes this issue #109

@timbec
Copy link

timbec commented Jan 23, 2020

@alfarhanzahedi Tried it after finding the same problem and not of the other solutions above worked (for me). Works! Thanks!

agusmakmun added a commit that referenced this issue Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants