Another bit of info, just in case anyone is currently looking at this..

The error is coming from
/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py

class BooleanField(Field):
    empty_strings_allowed = False
    default_error_messages = {
        *'invalid': _("'%s' value must be either True or False."),*
    }
    description = _("Boolean (Either True or False)")

    def __init__(self, *args, **kwargs):
        kwargs['blank'] = True
        if 'default' not in kwargs and not kwargs.get('null'):
            kwargs['default'] = False
        Field.__init__(self, *args, **kwargs)

    def get_internal_type(self):
        return "BooleanField"

    def to_python(self, value):
        if value in (True, False):
            # if value is 1 or 0 than it's equal to True or False, but we
want
            # to return a true bool for semantic reasons.
            return bool(value)
        if value in ('t', 'True', '1'):
            return True
        if value in ('f', 'False', '0'):
            return False
        *msg = self.error_messages['invalid'] % value*
        raise exceptions.ValidationError(msg)


So it's failing validation because it's seeing the field as a BooleanField,
when I quite obviously have set it as a CharField.

I'm absolutely stuck.

On 3 May 2013 11:13, Darren Mansell <[email protected]> wrote:

> Bit more info (all pointing to the same database / db server):
>
> test server with Django dev server : works
> test server with Apache 2.2.22-6ubuntu5 / mod-wsgi 3.4-0ubuntu3 : works
>
> live server with Django dev server : works
> live server with Apache 2.2.22-1ubuntu1.3 / mod-wsgi 3.3-4build1 : doesn't
> work
>
>
>
>
> On 3 May 2013 10:35, Darren Mansell <[email protected]> wrote:
>
>> Hi all. Really really confused by this one. Can someone show me where I'm
>> being stupid please?
>>
>> Standard Django 1.5.1 app with MySQL. Trying to save to a VARCHAR(3)
>> column with a forms.CharField form field and a models.CharField model field.
>>
>> When I try to save the form I get this validation error:
>>
>> [image: Inline images 1]
>>
>>
>> This is the MySQL column definition:
>>
>> `customers_impacted` varchar(3) DEFAULT NULL,
>>
>>
>> This is from forms.py (it's a ModelForm):
>>
>> YES_NO = (
>>         ('No', 'No'),
>>         ('Yes', 'Yes'),
>>         )
>> customers_impacted =
>> forms.CharField(widget=forms.Select(choices=YES_NO),max_length=3)
>>
>>
>> This is from models.py:
>>
>> customers_impacted = models.CharField(max_length=3)
>>
>>
>> The field was originally a BooleanField but I changed it to CharField and
>> I can't see anywhere it could still be getting the Boolean / True / False
>> info from.
>>
>> Strangely, it works fine using the development server, but this error
>> happens when using Apache + mod_wsgi. I've rebooted the server, restarted
>> everything, tried changing collation etc.
>>
>> Could anyone suggest anything? Any extra logging etc I can turn on
>> somewhere to show where the validation is failing?
>>
>> Thanks.
>> Darren (confused)
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


<<snapshot1.png>>

Reply via email to