locale/django.po文件有7868行.有时makemessages命令工作,有时它抛出这个错误:它很奇怪,因为在错误中总是提到django.pot的不同行.并且不要忘记它有时使用相同的代码,因此代码应该没问题
manage.py makemessages -l de
CommandError: errors happened while running msguniq
/app/xxx/locale/django.pot:1871: /app/xxx/locale/django.pot: input is not valid in "ASCII" encoding
Run Code Online (Sandbox Code Playgroud) 我有一个 shell 脚本 .sh 来停止和删除正在运行的容器,通常效果很好。但十分之一的情况是该docker rm命令似乎在完成之前就已执行docker stop,因此会引发容器仍在运行的错误。我可以做什么来防止该错误?
docker stop nostalgic_shirley
docker rm nostalgic_shirley
Run Code Online (Sandbox Code Playgroud)
输出
nostalgic_shirley
nostalgic_shirley
Error response from daemon: You cannot remove a running container xxxx. Stop the container before attempting removal or force remove
Run Code Online (Sandbox Code Playgroud)
如果我随后尝试再次使用docker rm nostalgic_shirley,效果很好。
我不应该使用docker stop --force,因为关闭应该是优雅的
class User(models.Model):
email = models.EmailField()
name = models.CharField()
Run Code Online (Sandbox Code Playgroud)
如何以元组列表的形式获取用户的电子邮件和名称?我目前的解决方案是这样的:
result = []
for user in User.objects.all():
result.append((user.email, user.name))
Run Code Online (Sandbox Code Playgroud) 我有这个代码,想缩短它.这有可能吗?拥有通常相同的代码并没有多大意义:
try:
years = values['year']
except KeyError:
pass
try:
tracks = values['track']
except KeyError:
pass
try:
statuses = values['status']
except KeyError:
pass
Run Code Online (Sandbox Code Playgroud)
python ×3
django ×2
docker ×1
gettext ×1
optimization ×1
performance ×1
sh ×1
shell ×1
translation ×1