def _has_field(cls, name): try: cls._meta.get_field(name) return True except models.fields.FieldDoesNotExist: return hasattr(cls, name)