On Wed, Jul 14, 2010 at 1:45 PM, rmschne <[email protected]> wrote: > As I understand, in Django/Python, True is 1 and False=0. And when > connected to the database, we use a TinyInt for that variable and > assign it to a NullBooleanField.
True and False are global objects of type bool, not 1 and 0. bool constructor converts integers to True/False as appropriate. > > Problem is that some people use their PC's with a Microsoft Access > based front end to the database (MySQL). The forms use check-boxes, > and when checked, which is supposed be "true", Access puts -1 into the > data base. Django doesn't recognize that value as True. Yes, Access is dire. I think you can probably count the number of people using Access as a front end to django on one hand (possibly one hand with four fingers cut off). > > I can't change the Access forms or system and don't tell me to stop > using Access. We don't have unlimited resources to fix all the > problems in the world! > > I'm wondering if there is some way to tell Django in the data model to > let a model variable return True when <>0 (instead of when=1) , and > False when 0? > > This seems the cleanest easiest way; but I can't see how to make this > possible? Is it? Or is there another approach ? > Define a MyBooleanField that extends models.BooleanField, override to_python(). Use that instead of models.BooleanField. Docs on that: http://docs.djangoproject.com/en/1.2/howto/custom-model-fields/ Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

