On Fri, 2007-07-13 at 09:53 +0800, Russell Keith-Magee wrote: > > Check the attributes of field - amongst many others, there is > field.name, the name of the field on the form. So, you can do the > following: > > if isinstance(field, models.DateField) and field.name == 'appointment': > ...
Could have sworn I'd checked that. Here's what I get with the latest from trunk: >>> from django.newforms.models import form_for_instance >>> FormClass = form_for_instance(Title.objects.all()[0]) >>> form = FormClass() >>> form.fields {'name': <django.newforms.fields.CharField object at 0x865e04c>, 'author': <django.newforms.fields.CharField object at 0x865e06c>, 'publisher': <django.newforms.fields.CharField object at 0x865e08c>, 'isbn': <django.newforms.fields.CharField object at 0x865e0ac>, 'num_pages': <django.newforms.fields.IntegerField object at 0x865e0cc>, 'dimensions': <django.newforms.fields.CharField object at 0x865e0ec>, 'weight': <django.newforms.fields.DecimalField object at 0x865e10c>, 'picture_url': <django.newforms.fields.URLField object at 0x865e12c>} >>> dir(form.fields['name']) ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__slotnames__', '__str__', '__weakref__', 'clean', 'creation_counter', 'help_text', 'hidden_widget', 'initial', 'label', 'max_length', 'min_length', 'required', 'widget', 'widget_attrs'] No name in there... Todd --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---