Friday, January 19, 2018

Need to create an edit box connected to one table field



I need to create an edit box called handicapped with three drop down options on the display:
  0 - none
  1 - Mental
  2 - Phyiscal

and connect it to the handicapped field init(11) in the family database

I know I have to do something like:

            if form['handicapped'].data == 1 or 2:
                q = context['child_filter'].filter(Q(handicapped=handicapped_dict[request.POST['handicapped']]))

# start of output using search parameters

            if q.count() > 1:
              search_message = "There are %s children that match your selection of %s"  %  (q.count(), request.POST['gender'])
            else:
              search_message = "There is 1 child that matches your selection of %s"  %  (request.POST['gender'])

            if q.count() > 1:
               search_message = ", age: %s"  %  (request.POST['age'])
            else:
               search_message = ", age: %s"  % (request.POST['age'])

            if form.data['handicapped'] is 'Physical' or 'Mental':
               if q.count() > 1:
                  search_message = ", is %s handicapped" %  (request.POST['handicapped'])
               elif q.count() == 1:
                  search_message = ", is %s handicapped" % (request.POST['handicapped'])
            else:
                search_message = ", are %s handicapped" % (request.POST['handicapped'])

but it doesn't _work at all_.

The database is defined all right, I should say.

I get lots of different types of errors - sorry I can't include them now, but definitely not week if the problem is still outstanding.

-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/538b8651-fcf9-4310-abe6-baae7d7b1f56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment