Why in Django the field IntegerRangeField not worked with None?

115 views
Skip to first unread message

Seti Volkylany

unread,
Jun 15, 2016, 6:09:16 AM6/15/16
to Django users
The model next:

class Writter(models.Model):
   
"""
    Model for writters of books
    """


    id
= models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4)
    name
= models.CharField(
        _
('Name'),
        max_length
=200,
        validators
=[MinLengthValidator(settings.MIN_LENGTH_FOR_NAME_OR_TITLE_OBJECT)],
        unique
=True,
        error_messages
={'unique': _('The such writter already is here.')}
   
)
    slug
= ConfiguredAutoSlugField(_('Slug'), populate_from='name', unique=True)
   
#
   
# basic trends of books
   
#
    about
= models.TextField(
        _
('About writter'),
        validators
=[MinLengthValidator(100)],
        help_text
=_('Give brief character of the writter and his books.')
   
)
    years_life
= IntegerRangeField(
        _
('years life'),
       
null=True,
        blank
=True,
        help_text
='Enter year birth and year death, if have.'
   
)



I am tried next:

 Writter.objects.filter(years_life__endswith=None)

but found error:

    allow_joins)
       
998         if value is None:
       
999             if lookups[-1] not in ('exact', 'iexact'):
   
-> 1000                 raise ValueError("Cannot use None as a query value")
       
1001             lookups[-1] = 'isnull'
       
1002             value = True
   
   
ValueError: Cannot use None as a query value


Sergiy Khohlov

unread,
Jun 16, 2016, 2:43:11 PM6/16/16
to django-users
Look like it is expected behaviour. 
filter builds sql, any sql should have sence. What is sence with broken sql ? 

Many thanks,

Serge


+380 636150445
skype: skhohlov

--
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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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/72566fb6-79ba-416c-9e3f-7b07a7df6e3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages