Developer 2024 🎇限时优惠进行中,现在购买立即享受

现在购买

django 3.2x 提示 default_auto_field attribute to point to a subclass of AutoField 解决办法

avatar社区小助手
2月12日1.2k次阅读

警告详情

(models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
    HINT: Configure the DEFAULT_AUTO_FIELD setting or the DemoConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.

解决办法

可以在settings.py中配置这句

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
发布评论
登录后发表内容
0个评论