The goal is to have "API methods that let you introspect the fields and relations that exist on a model", right? Why go though the trouble of finding the one specific type for each field (that we'll never be able to change later)? Why have a get_fields() method with an ever-growing number of kwargs?
I want all "related" fields. Easy: (f for f in _meta.fields if hasattr(f, 'rel')) I want all read-only fields. Easy: (f for f in _meta.fields if not f.editable) I want all fields that can be edited through a form. Something like: (f for f in _meta.fields if hasattr(f, 'formfield')) I want all "local" fields (not that you should care). Easy: (f for f in _meta.fields if f.model == _meta.model) I want all fields that have an actual column in the database. Something like (f for f in _meta.fields if f.db_type()) I want all fields that function like a ManyToMany. Easy: (f for f in _meta.fields if f.get_internal_type() == 'ManyToManyField') I want all fields that have ForeignKey.to_field pointing to them. Something like: set(_meta.get_field(fname) for rel in _meta.related for fname in rel.to_fields) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/76a3d23b-9367-451c-b22b-f89c143ed4dd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
