1
有没有办法避免get_or_create方法上的“未使用变量”警告?django:在get_or_create上避免“未使用变量”警告
level,created= Level.objects.get_or_create(name='Alumnes x Classificar')
因为我不需要读取created
变量,所以IDE显示一个警告。
我知道一个微不足道的解决方案,我使用变量,有些东西,如:if create: pass
但我正在寻找一个更优雅的解决方案。
见你!
此解决方案似乎比放置子索引更优雅。我会尝试这个。 – danihp
它的工作原理!谢谢。 – danihp
,但我会认为这是一个糟糕的做法,因为在Django中'_'主要用作可转换字符串的var。 https://docs.djangoproject.com/en/1.10/topics/i18n/translation/#standard-translation。我在行尾使用'#nopa' – patroqueeet