On Wed, 2008-11-19 at 09:42 -0800, Delta20 wrote: > A model field may have a 'choices' option to which you assign an > iterable object -- typically a list, but this can also be an iterable > function. Is there a way to assign a class method/function rather than > a module function?
No. Python differentiates between functions and methods on a class (particularly, bound methods are separate from functions). The latter require a "self" parameter, which is why there's a difference. You can use an unbound method where a function is expected, but then the caller has to know to pass in the equivalent of "self" as the first argument. There are a number of places in Django that accept a function, but aren't in a position to pass in "self" (and we don't want to do the introspection every time to work out if it's necessary, even if that was always possible, since it's almost always unnecessary overhead). So the real issue here is that the model instance isn't used when computing the choices. That's just the way things are. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---