Skip to main content

This package marries Django with CodeMirror

Project description

This package marries Django with CodeMirror.

rationale

  • You can enable vim mode :)

usage

installation

This is a standard Python 3 package without dependencies (apart from Django itself) offered at the Cheese Shop:

# usually inside a virtual environment
pip install django-mirror

And then you have to add django_mirror to the INSTALLED_APPS setting of your Django project.

widget

To django-mirror textarea is provided as a form widget:

from django import forms
from django_mirror.widgets import MirrorTextarea

class CommentForm(forms.Form):
    text = forms.CharField(widget=MirrorTextarea(mode='markdown'))

admin

To use the django-mirror textarea widget in the admin panel you can subclass the respective model form. But you can also use the admin mixin provided by the library:

from django.contrib import admin
from django_mirror.admin import MirrorAdmin

from weblog.models import Comment


@admin.register(Comment)
class CommentAdmin(MirrorAdmin, admin.ModelAdmin):
    mirror_fields = ('comment',)  # default options
    mirror_fields = (  # with custom options
        ('comment', {
            'mode': 'markdown',
        })
    )

uploads

licence

GPL. You can do what you want with this code as long as you let others do the same.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-mirror-0.1.0.tar.gz (432.3 kB view hashes)

Uploaded Source

Built Distribution

django_mirror-0.1.0-py3-none-any.whl (533.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page