In a django custom field, what does the SubfieldBase metaclass do?
问题 When you implement a custom Django field, you're supposed to include this line: __metaclass__ = models.SubfieldBase in the class definition, as in: class SomeCustomField(models.Field): __metaclass__ = models.SubfieldBase What does that actually do? Update: This is the source code for the metaclass (from the Django project): class SubfieldBase(type): """ A metaclass for custom Field subclasses. This ensures the model's attribute has the descriptor protocol attached to it. """ def __new__(cls,