mirror of
https://github.com/Hopiu/django-modeltranslation.git
synced 2026-05-24 04:03:45 +00:00
Make ClearableWidgetWrapper compatible with Django 1.6 (_has_changed).
This commit is contained in:
parent
b38949aaa5
commit
81c9d55c1e
2 changed files with 15 additions and 7 deletions
|
|
@ -21,3 +21,9 @@ class NullableField(object):
|
|||
if value is None:
|
||||
return value
|
||||
return super(NullableField, self).to_python(value)
|
||||
|
||||
# Django 1.6
|
||||
def _has_changed(self, initial, data):
|
||||
if (initial is None and data is not None) or (initial is not None and data is None):
|
||||
return True
|
||||
return super(NullableField, self)._has_changed(initial, data)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django import VERSION
|
||||
from django.forms.widgets import Media, Widget, CheckboxInput
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.safestring import mark_safe
|
||||
|
|
@ -84,13 +85,14 @@ class ClearableWidgetWrapper(Widget):
|
|||
return self.empty_value
|
||||
return self.widget.value_from_datadict(data, files, name)
|
||||
|
||||
def _has_changed(self, initial, data):
|
||||
"""
|
||||
Widget implementation equates ``None``s with empty strings.
|
||||
"""
|
||||
if (initial is None and data is not None) or (initial is not None and data is None):
|
||||
return True
|
||||
return self.widget._has_changed(initial, data)
|
||||
if VERSION < (1, 6): # In Django 1.6 formfields should implement _has_changed
|
||||
def _has_changed(self, initial, data):
|
||||
"""
|
||||
Widget implementation equates ``None``s with empty strings.
|
||||
"""
|
||||
if (initial is None and data is not None) or (initial is not None and data is None):
|
||||
return True
|
||||
return self.widget._has_changed(initial, data)
|
||||
|
||||
def clear_checkbox_name(self, name):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue