Having read through [1] and experimented with it a bit, I've been unable to determine whether my failure is due to a Django limitation or if it's my own fault. My question comes in two parts:

1) Can a custom model-field interface with more than one DB field? The .db_type() method's return-signature seems to suggest a one-to-one restriction between model fields and database fields.

2) Can one create custom lookups for db_prep_lookup beyond the 21 listed lookup-names under its documentation?

Further details:

I'm trying to create a custom model-field that jockeys 4 DB fields into and out of a single Python class. The intended interface is something like

  class MyModel(Model):
    dob = AmbiguousDate()

which would yield a table with fields

  dob_year_min
  dob_year_max
  dob_month
  dob_day

and jockey those into and out of the MyModel.dob class. The intention is that any of those pieces may be null (you might know the day/month of the birthday but not the year; you might have a general age-range to know that a person is between 35-40; you might know a person was born in Feb of 1965, but not the day; etc).

For the 2nd item, I'd like to .filter(dob__age_range=(45,50)) in addition to .filter(dob__range=(date1, date2)) using my Model Field code to generate a corresponding SQL query string.

Thanks for any pointers/tips,

-Tim


[1]
https://docs.djangoproject.com/en/dev/howto/custom-model-fields/



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to