Skip to content

Commit

Permalink
Fixing issue with static_url setting overriding the user's since it r…
Browse files Browse the repository at this point in the history
…elied on an or that would eval

to the user's media_url. Also modified the ModelAdmins to only override the MarkdownFields instead of
Textfields so that Textfields display normally unless users specify it as MarkdownField's.
  • Loading branch information
wldcordeiro committed Dec 5, 2014
1 parent 6e59652 commit 63c1621
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[bumpversion]
commit = True
current_version = 0.8.0
current_version = 0.8.1
files = django_markdown/__init__.py
tag = True
tag_name = {new_version}
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Contributors:
* Sergii Iavorskyi (https://github.com/yavorskiy)
* Tom O'onnor' (https://github.com/tomoconnor)
* dfeinzeig (https://github.com/dfeinzeig)
* Wellington Cordeiro (https://github.com/wldcordeiro)
5 changes: 5 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2014-12-04 wldcordeiro
* Removed static_url setting from package settings due to collision with user setting.
* Modified the ModelAdmins to only override MarkdownFields since some users want normal Textfields to display normall.
* Version 0.8.1

2014-09-25 horneds

* Remove python2.6, Django 1.4 support
Expand Down
9 changes: 8 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ Use django_markdown
from django_markdown.admin import MarkdownModelAdmin
admin.site.register(MyModel, MarkdownModelAdmin)

#) 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}}

#) Flatpages: ::

# in your project main urls
Expand Down Expand Up @@ -172,7 +179,7 @@ Contributors

* klen_ (Kirill Klenov)

* yavorskiy_ (Sergii Iavorskyi)
* yavorskiy_ (Sergii Iavorskyi)


License
Expand Down
5 changes: 3 additions & 2 deletions django_markdown/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
from django.db import models

from django_markdown.widgets import AdminMarkdownWidget
from django_markdown.models import MarkdownField


class MarkdownModelAdmin(admin.ModelAdmin):

""" Support markdown as ModelAdmin. """

formfield_overrides = {models.TextField: {'widget': AdminMarkdownWidget}}
formfield_overrides = {MarkdownField: {'widget': AdminMarkdownWidget}}


class MarkdownInlineAdmin(admin.StackedInline):

""" Support markdown as StackedInline. """

formfield_overrides = {models.TextField: {'widget': AdminMarkdownWidget}}
formfield_overrides = {MarkdownField: {'widget': AdminMarkdownWidget}}
1 change: 0 additions & 1 deletion django_markdown/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
MARKDOWN_STYLE = getattr(settings, 'MARKDOWN_STYLE', 'django_markdown/preview.css')
MARKDOWN_PROTECT_PREVIEW = getattr(settings, 'MARKDOWN_PROTECT_PREVIEW', False)

STATIC_URL = settings.STATIC_URL or settings.MEDIA_URL
LOGIN_URL = settings.LOGIN_URL
4 changes: 3 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
# ------
from django.db import models

from django_markdown.models import MarkdownField

class Test(models.Model):
content = models.TextField()
content = MarkdownField()

class Meta:
app_label = 'test'
Expand Down

0 comments on commit 63c1621

Please sign in to comment.