def contribute_to_class(self, cls, name): self.item_field_type.model = cls self.item_field_type.name = name super(IterableField, self).contribute_to_class(cls, name) # If items' field uses SubfieldBase we also need to. item_metaclass = getattr(self.item_field_type, '__metaclass__', None) if item_metaclass and issubclass(item_metaclass, models.SubfieldBase): setattr(cls, self.name, Creator(self))
def contribute_to_class(self, cls, name): self.item_field.model = cls self.item_field.name = name super(AbstractIterableField, self).contribute_to_class(cls, name) # If items' field uses SubfieldBase we also need to. item_metaclass = getattr(self.item_field, '__metaclass__', None) if item_metaclass and issubclass(item_metaclass, models.SubfieldBase): setattr(cls, self.name, Creator(self)) if isinstance(self.item_field, models.ForeignKey) and isinstance(self.item_field.rel.to, basestring): """ If rel.to is a string because the actual class is not yet defined, look up the actual class later. Refer to django.models.fields.related.RelatedField.contribute_to_class. """ def _resolve_lookup(_, resolved_model, __): self.item_field.rel.to = resolved_model self.item_field.do_related_class(self, cls) add_lazy_relation(cls, self, self.item_field.rel.to, _resolve_lookup)
def contribute_to_class(self, cls, name): super(MultiEmailField, self).contribute_to_class(cls, name) setattr(cls, name, Creator(self))