Giter Club home page Giter Club logo

django-pagedown's Introduction

Django Pagedown

A django app that allows the easy addition of Stack Overflow's "Pagedown" Markdown editor to a django form field, whether in a custom app or the Django Admin


Screenshot of Django Admin with Pagedown initialised


Installation

  • Install via pip: pip install -e https://[email protected]/timmyomahony/django-pagedown.git#egg=django-pagedown for the latest version, otherwise 'pip install django-pagedown'
  • Add pagedown to your INSTALLED_APPS

Note that this package will install a cloned copy of the Pagedown library from http://github.com/timmyomahony/pagedown/

Usage

If you want to use the pagedown editor in a django admin field, there are numerous possible approaches:

To use it in all TextField's in you admin form:

from pagedown.widgets import AdminPagedownWidget
from django.db import models
class FooModelAdmin(models.ModelAdmin):
	formfield_overrides = {
    	models.TextField: {'widget': AdminPagedownWidget },
	}

Alternatively, to only use it on particular fields, first create a form (in forms.py):

from pagedown.widgets import AdminPagedownWidget
from django import forms
from models import FooModel

class FooModelForm(forms.ModelForm):
	a_text_field = forms.CharField(widget=AdminPagedownWidget())		
	another_text_field = forms.CharField(widget=AdminPagedownWidget())	
	
	class Meta:
		model = FooModel

and in your admin.py:

from forms import FooModelForm
class FooModelAdmin(models.ModelAdmin):
	form = FooModelForm   

Notes

  • There are two widgets, AdminPageDownWidget and PageDownWidget. The only difference is that AdminPageDownWidget includes extra CSS to make the preview area and input pretty in the django admin. If you are using the editor for your own app, you will need to supply CSS to do this.

django-pagedown's People

Contributors

fin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.