在Django admin页面,给 和IndexPromotionBanner相关的 数据表 添加数据时,遇到如下图的错误:

Invalid URL
IndexPromotionBanner模型类的定义:

IndexPromotionBanner模型
从模型类IndexPromotionBanner的定义 可知:活动链接对应字段为URLField。
但是填写普通的字符串,仍是报错。

URLField

URLValidator
从上面两图 可得知:
URLField要经过URLValidator的验证URLValidator验证URL时,使用schemes方案。从中看到了'http', 'https', 'ftp', 'ftps' 于是在url字符串前,加上了http://, 结果不报错了。
因此,正确的url形式是:http://127.0.0.1:8000