Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的字段models.py是EmailField和URLField。当我调用get_internal_type()这些方法时,方法返回CharField而不是EmailFieldand URLField。
models.py
EmailField
URLField
get_internal_type()
CharField
我希望它成为EmailField并URLField进行进一步处理。
如果您需要对这些类型进行特殊处理,请改用类的名称:
type(field).__name__ # get name of the field class, instead of field.get_internal_type()
两者EmailField和URLField 都是 Charfield子类,仅具有预设的最大长度和专用的验证器。
Charfield