On Friday 16 June 2017 07:33:22 Priyanka Thakur wrote:
> Hi,
>
> I am doing migration from Django 1.7 to 1.10 version and has a custom
> django field.
>
> Below is the custom class for the field:
>
> ----
>
> from django.db import models
>
>
>
> class HibernateBooleanField(models.BooleanField):
>
> def from_db_value(self, value, expression, connection, context):
>
> return self.to_python(value)
>
>
> def get_internal_type(self):
>
> return "HibernateBooleanField"
>
>
> def db_type(self, connection):
>
> return 'bit(1)'
>
>
> def to_python(self, value):
>
> if value in (True, False):
>
> return value
>
> if value in ('t', 'True', 'true', '1', '\x01'): return True
>
> if value in ('f', 'False', 'false', '0', '\x00', None): return
> False
and if value is something else, nothing (aka None) is returned. You have no
else clause here.
--
Melvyn Sopacua
--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/7550235.97tRNztyJN%40devstation.
For more options, visit https://groups.google.com/d/optout.