From 1ddacf1e73c1708eeadc4643066df96b469db666 Mon Sep 17 00:00:00 2001 From: adi <> Date: Thu, 26 Dec 2019 14:48:21 +0100 Subject: [PATCH] Removing support of Django < 2 --- markdownx/templates/markdownx/widget.html | 2 +- markdownx/templates/markdownx/widget2.html | 4 ---- markdownx/widgets.py | 28 ++++------------------ 3 files changed, 5 insertions(+), 29 deletions(-) mode change 100755 => 100644 markdownx/templates/markdownx/widget.html delete mode 100644 markdownx/templates/markdownx/widget2.html diff --git a/markdownx/templates/markdownx/widget.html b/markdownx/templates/markdownx/widget.html old mode 100755 new mode 100644 index b795aac..db58978 --- a/markdownx/templates/markdownx/widget.html +++ b/markdownx/templates/markdownx/widget.html @@ -1,4 +1,4 @@
- {{ markdownx_editor }} + {% include 'django/forms/widgets/textarea.html' %}
diff --git a/markdownx/templates/markdownx/widget2.html b/markdownx/templates/markdownx/widget2.html deleted file mode 100644 index db58978..0000000 --- a/markdownx/templates/markdownx/widget2.html +++ /dev/null @@ -1,4 +0,0 @@ -
- {% include 'django/forms/widgets/textarea.html' %} -
-
diff --git a/markdownx/widgets.py b/markdownx/widgets.py index 3e78c86..4072c91 100755 --- a/markdownx/widgets.py +++ b/markdownx/widgets.py @@ -19,9 +19,6 @@ except ImproperlyConfigured: # Documentations work around. DEBUG = False -# For backward compatiblity methods. -is_post_10 = DJANGO_VERSION[:2] > (1, 10) - minified = '.min' if not DEBUG else str() @@ -31,15 +28,12 @@ class MarkdownxWidget(forms.Textarea): Django "TextArea" widget. """ - template_name = 'markdownx/widget{}.html'.format('2' if is_post_10 else str()) + template_name = 'markdownx/widget.html' def get_context(self, name, value, attrs=None): """ - Context for the template in Django 1.10 or below. + Context for the template in Django """ - if not is_post_10: - return super(MarkdownxWidget, self).get_context(name, value, attrs) - try: attrs.update(self.add_markdownx_attrs(attrs)) except AttributeError: @@ -49,26 +43,12 @@ class MarkdownxWidget(forms.Textarea): def render(self, name, value, attrs=None, renderer=None): """ - Rendering the template and attributes thereof in Django 1.11+. - - .. Note:: - Not accepting ``renderer`` is deprecated in Django 1.11. + Rendering the template and attributes """ attrs.update(self.attrs) attrs.update(self.add_markdownx_attrs(attrs)) - if is_post_10: - return super(MarkdownxWidget, self).render(name, value, attrs, renderer) - - attrs = self.build_attrs(attrs, name=name) - - widget = super(MarkdownxWidget, self).render(name, value, attrs) - - template = get_template(self.template_name) - - return template.render({ - 'markdownx_editor': widget, - }) + return super(MarkdownxWidget, self).render(name, value, attrs, renderer) @staticmethod def add_markdownx_attrs(attrs):