- def formfield(self, *args, **kwargs):
- field = self.field_template.formfield(*args, **kwargs)
- field.required = False
- return field
+ def contribute_to_class(self, cls, name):
+ super(AttributeField, self).contribute_to_class(cls, name)
+ if self.key is None:
+ self.key = name
+
+ def formfield(self, **kwargs):
+ defaults = {'required': False, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
+ defaults.update(kwargs)
+ return self.field_template.formfield(**defaults)