filter none on django field -


i have model person has nothing in birth_date field. here example:

(pdb) dude = person.objects.get(pk=20) (pdb) dude <person: bob mandene> (pdb) dude.birth_date (pdb) dude.birth_date == none true 

how filter these records have birth_date == none?

i have tried following no success:

1: "birth_date__isnull" not work.

 person.objects.filter(birth_date__isnull = true)   # not return required   # object.    returns record have birth_date set   # null when table observed in mysql. 

the following not return the record id 20.

person.objects.filter(birth_date = "") 

how filter on field being none? seems null , none different. when see data using sequel pro (mysql graphical client) see "0000-00-00 00:00:00", , following did not work either

(pdb) ab=patient.objects.filter(birth_date = "0000-00-00 00:00:00")  validationerror: [u"'0000-00-00 00:00:00' value has correct format   (yyyy-mm-dd     hh:mm[:ss[.uuuuuu]][tz]) invalid date/time."] 

model

class person(models.model):     person_no = models.integerfield(primary_key=true)     locationid = models.integerfield(null=true, db_column='locationid', blank=true)      address =  models.foreignkey('address', db_column = 'address_no')     birth_date = models.datetimefield(null=true, blank=true)     class meta:        managed = false        db_table = 'person' 

null in mysql turns none in python, had birth_date__isnull=true should returning have birth_date none.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -