def check_formfield(cls, model, opts, label, field): if getattr(cls.form, 'base_fields', None): try: cls.form.base_fields[field] except KeyError: raise ImproperlyConfigured("'%s.%s' refers to field '%s' that " "is missing from the form." % (cls.__name__, label, field)) else: fields = fields_for_model(model) try: fields[field] except KeyError: raise ImproperlyConfigured("'%s.%s' refers to field '%s' that " "is missing from the form." % (cls.__name__, label, field))
def test_empty_fields_to_fields_for_model(self): "An argument of fields=() to fields_for_model should return an empty dictionary" field_dict = fields_for_model(Person, fields=()) self.assertEqual(len(field_dict), 0)