Hello Djeople,

Trolling for criticism, broader use-cases, or a lurking solution for my
latest problem: Say you've got a model with two fields 'primary_lang' and
'secondary_lang' and you'd like to filter across them in one fell swoop. The
obvious solution is to make a manager method filterlang('foo') which
conducts a Q(primary_lang='foo')|Q(secondary_lang='foo') under the hood.

Fine and dandy until your boss asks you to create a Report Generator (or
something) which takes arbitrary fields from your model and wants to report
on them. Trying to get this generator to use your custom model method would
be a sinch, except the fields (primary_lang, secondary_lang) are totally
ignorant as to how they ought to be filtered.

You could override filter() (please, save your groans), but its not obvious
to later maintainers why it would work, and getting it to function for all
queries is tedious. See Also:Yak Shaving (Tredinnick, et al).

My thinking at this point is you could create a PseudoField which has its
own model manager-ish logic and attach it to the model, then somehow have
the model catch the FieldError which is certain to arise, and check for one
last hurrah among PseudoFields for results, and then returning them.

That's the best I got so far. Thoughts?

-Steve

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to