django-markdown-gcir

Django markdown support and wysiwyg.


Keywords
html markdown django
License
LGPL-2.1+
Install
pip install django-markdown-gcir==0.1.0

Documentation

django-markdown-gcir v. 0.1.0

Django markdown is django application that allows use markdown wysiwyg in flatpages, admin forms and other forms. Documentaton available at pypi or github.

Requirements

  • python >= 3.6
  • django >= 2.0
  • markdown

Installation

Django markdown should be installed using pip:

pip install django-markdown-gcir

Setup

Note

'django_markdown' require 'django.contrib.staticfiles' in INSTALLED_APPS

  • Add 'django_markdown' to INSTALLED_APPS

    INSTALLED_APPS += ( 'django_markdown', )
    
  • Add django_markdown urls to base urls

    re_path('^markdown/', include('django_markdown.urls')),
    

Use django_markdown

  1. Models:

    from django_markdown.models import MarkdownField
    
    
    class MyModel(models.Model):
        content = MarkdownField()
    
  2. Custom forms:

    from django_markdown.fields import MarkdownFormField
    from django_markdown.widgets import MarkdownWidget
    
    
    class MyCustomForm(forms.Form):
        content = forms.CharField(widget=MarkdownWidget())
        content2 = MarkdownFormField()
    
  3. Custom admins:

    from django_markdown.admin import MarkdownModelAdmin
    
    admin.site.register(MyModel, MarkdownModelAdmin)
    
  4. Admin Overrides: (If you don't want to subclass package ModelAdmin's)

    from django.contrib import admin
    
    
    class YourModelAdmin(admin.ModelAdmin):
        formfield_overrides = {MarkdownField: {'widget': AdminMarkdownWidget}}
    
  5. Flatpages:

    # in your project main urls
    from django_markdown import flatpages
    ...
    # Django admin
    admin.autodiscover()
    flatpages.register()
    urlpatterns += [ re_path(r'^admin/', include(admin.site.urls)), ]
    
  6. Template tags:

    <textarea name="test" id="new"></textarea>
    {% markdown_editor "#new" %}
    {% markdown_media %}
    

Settings

MARKDOWN_EDITOR_SETTINGS - holds the extra parameters set to be passed to textarea.markItUp()

MARKDOWN_EDITOR_SKIN - skin option, default value is markitup

Example: settings.py

MARKDOWN_EDITOR_SKIN = 'simple'

MARKDOWN_EXTENSIONS - optional list of extensions passed to Markdown, discussed at https://pythonhosted.org/Markdown/extensions/index.html#officially-supported-extensions

Example: settings.py

MARKDOWN_EXTENSIONS = ['extra']

MARKDOWN_EXTENSION_CONFIGS - Configure extensions, discussed at https://pythonhosted.org/Markdown/reference.html#extension_configs

MARKDOWN_PREVIEW_TEMPLATE - Template for preview a markdown. By default django_markdown/preview.css

MARKDOWN_STYLE - path to preview styles. By default django_markdown/preview.css

MARKDOWN_SET_PATH - path to folder with sets. By default django_markdown/sets

MARKDOWN_SET_NAME - name for current set. By default markdown.

MARKDOWN_PROTECT_PREVIEW - protect preview url for staff only

Examples

Execute make run in sources directory. Open http://127.0.0.1:8000 in your browser. For admin access use 'root:root' credentials.

Changes

Make sure you`ve read the following document if you are upgrading from previous versions:

http://packages.python.org/django-markdown/changes.html

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/django_markdown/issues

Contributing

Development of original django-markdown happens at github: https://github.com/klen/django_markdown Development of django-markdown-gcir happens also at github: http://github.com/Ge0/django-markdown-gcir

Contributors

  • klen (Kirill Klenov)
  • yavorskiy (Sergii Iavorskyi)
  • Ge0 (Geoffrey ROYER)

License

Licensed under a GNU lesser general public license.

Copyright

Copyright (c) 2011 Kirill Klenov (horneds@gmail.com)

Markitup:
(c) 2008 Jay Salvat http://markitup.jaysalvat.com/