On 07-May-18, at 6:33 AM, Malcolm Tredinnick wrote:
> > On Thu, 2007-05-17 at 20:08 -0700, David Priest wrote: >> It occurs to me that were I able to write the following: >> models_list = ( >> 'project.app1.models.Claim', >> 'project.app2.models.Vendor') > > Why is this needed? Couldn't you require that the fields_list strings > are python access paths referring to things that are already imported? Hey, if that's possible, so much the better. >> fields_list = ( >> 'Claim.vendor', >> 'Task.title', >> 'Task.description', >> 'Claim.claimed_cost', >> 'Claim.outcome', >> 'Claim.credit') >> __metaclass__ = MyMMF > > What does the metaclass do? Is this a replacement metaclass for the > Forms metaclass? A replacement metaclass for MetaModelForm.py or WTFForm or so on. Seems to be the common way of accomplishing this sort of functionality. How they actually work remains opaque to me. >> I could have a class that would go through fields_list and snarf down >> form fields from the models, akin to the process used by >> forms_for_model and forms_for_fields. >> >> The format I give above indicated the field ordering, which is quite >> handy; and tells the metaclass from which model classes to grab the >> fields. > > Now I'm really confused by the metaclass's purpose. If you're doing > something similar to forms_for_model aren't you wanting to create a > function (or class __init__() method, most likely) that takes the list > of fields and returns a Form subclass? Honest to god, I've no idea if metaclasses are the right way to do it. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---