Hi Melvyn,
Finally i had breakthrough and saw the root cause.
The issue is that i haven't defined any default value for this Custom field
in the model class.
As per Django 1.10 documentation, the default value of Boolean Field is
None if "default" value is not defined. Hence "None" value.
On Monday 19 June 2017 04:00:42 Priyanka Thakur wrote:
> On Monday, 19 June 2017 16:05:06 UTC+5:30, m712 - Developer wrote:
> > Melvyn was not saying whether you were checking for None. If `value`
> > is i.e. "some string" your to_python method will return `None`. You
> > should do something like
Oh, ok got the point !!
Thanks !!
Regards,
Priyanka
On Monday, 19 June 2017 16:05:06 UTC+5:30, m712 - Developer wrote:
>
> Melvyn was not saying whether you were checking for None. If `value` is
> i.e. "some string" your to_python method will return `None`. You should do
> something like
Melvyn was not saying whether you were checking for None. If `value` is i.e. "some string" your to_python method will return `None`. You should do something like this:
```
if value in ('t', ...): return True
elif value in ('f', ...): return False
else: return bool(value) # You can
Hi Melvyn,
I am checking for None in the last if condition in to_python method :
--copy--
> if value in ('f', 'False', 'false', '0', '\x00', *None*): return
> False
--copy--
Thanks for checking and replying !!
Regards,
Priyanka
On Friday, 16 June 2017 20:03:22 UTC+5:30, Priyanka Thakur
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
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):
7 matches
Mail list logo