forked from klen/django_markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue klen#37: Declare model field as MarkdownField and declare form …
…field as MarkdownFormField
- Loading branch information
Caroline Nadel
committed
Oct 25, 2014
1 parent
d2d953c
commit 0f1a76f
Showing
3 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django import forms | ||
from .widgets import MarkdownWidget | ||
|
||
|
||
class MarkdownFormField(forms.CharField): | ||
widget = MarkdownWidget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.db import models | ||
from .fields import MarkdownFormField | ||
|
||
|
||
class MarkdownField(models.TextField): | ||
def formfield(self, **kwargs): | ||
defaults = {'form_class': MarkdownFormField} | ||
defaults.update(kwargs) | ||
return super(MarkdownField, self).formfield(**defaults) |