Monday, January 29, 2018

Re: need to find out if someone is an orphan when I have mother_alive and father_alive fields in the database

Hi.

Your code is incomplete and actual error (whole traceback is missing)

Also you're trying to mix usage of form and reading post data directly. You should only use form to deal with user input. See https://docs.djangoproject.com/en/2.0/topics/forms/  for more information.

Finally with Q queries you don't use and-operator. See details at 
https://docs.djangoproject.com/en/2.0/topics/db/queries/#complex-lookups-with-q-objects


29.1.2018 22.04 <eileen@themaii.org> kirjoitti:
Hi,
I need to find out if someone is an orphan when I have mother_alive and father_alive fields in the database. Stepfathers, and stepmothers etc aren't counted when determining if someone is an orphan, only their birth mother, and birth father.
I tried 
  if form['orphaned'].data == True:
             q = context['child_filter'].filter(Q(request.POST.get('mother_alive') == 0 and request.POST.get('father_alive') == 0))

but I got an error on it.

does anyone know what I did wrong?

-Eileen



--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/f49ad522-cbcc-4aa9-8126-636231b36bfd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/CAHn91od-RRqAb%2BHqY%3DwGCCkO4S1JyjF-N5_CJc5QPmwkfQsPOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment