# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.db.models.fields import TextField
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible
from django.forms.util import ValidationError
from django.forms import TextInput
from isodate.isoerror import ISO8601Error
from thecut.durationfield.utils import isodate_to_relativedelta

try:
    from south.modelsinspector import add_introspection_rules
except ImportError:
    add_introspection_rules = None


@python_2_unicode_compatible
class DurationField(TextField):
    """Field (extended TextField) to accept ISO 8601 defined representation.
    """

    description = _("Duration of time in ISO 8601 representation")
    default_error_messages = {
        'invalid': _("This value must be in ISO 8601 Duration format."),
        'unknown_type': _("The value's type could not be converted"),
    }

    def formfield(self, *args, **kwargs):
        kwargs.update({'widget': TextInput})
        return super(TextField, self).formfield(*args, **kwargs)

    def get_internal_type(self):
        return "CharField"

    def to_python(self, value):
        """
        :py:class:`dateutil.relativedelta.relativedelta` is returned
        from ISO8601 duration formatted string or
        :py:class:`isodate.duration.Duration`.
        """
        try:
            isodate = isodate_to_relativedelta(value)
        except ISO8601Error:
            raise ValidationError(self.error_messages['invalid'])
        return isodate

if add_introspection_rules:
    add_introspection_rules([], ["^thecut\.durationfield\.fields"])


@@ -110,20 +110,20 @@
  import 
-Text
+Char
 Field%0Afr
@@ -288,43 +288,8 @@
 ror%0A
-from django.forms import TextInput%0A
 from
@@ -564,20 +564,20 @@
 onField(
-Text
+Char
 Field):%0A
@@ -599,20 +599,20 @@
 xtended 
-Text
+Char
 Field) t
@@ -729,16 +729,17 @@
 ation%22)%0A
+%0A
     defa
@@ -919,25 +919,24 @@
     def 
-formfield
+__init__
 (self, *
@@ -970,64 +970,50 @@
 args
-.update(%7B'widget': TextInput%7D)%0A        return super(Text
+%5B'max_length'%5D = 64%0A        super(Duration
 Fiel
@@ -1025,17 +1025,16 @@
 lf).
-formfield
+__init__
 (*ar
@@ -1423,24 +1423,24 @@
 O8601Error:%0A
-
             
@@ -1466,16 +1466,24 @@
 or(self.
+default_
 error_me

Revert "Inherit from TextField instead of CharField."