Django,1.9.10语言匹配查询不存在

时间:2016-10-24 17:13:39

标签: python linux django

我是一个苦苦挣扎的初学者,我将非常感谢你的帮助。 我已经克隆了一个Django网站来编辑和学习它,但我无法运行服务器。 在运行服务器上我收到错误 语言匹配查询不存在。

Request Method: GET
Request URL:    http://127.0.0.1:8000/en/software/features
Django Version: 1.9.10
Exception Type: DoesNotExist
Exception Value:    
Language matching query does not exist.
Exception Location: /home/steve/Documents/wger/venv-django/lib/python3.5/site-packages/django/db/models/query.py in get, line 387
Python Executable:  /home/steve/Documents/wger/venv-django/bin/python
Python Version: 3.5.2
Python Path:    
['/home/steve/Documents/wger/wger-croners',
 '/usr/lib/python35.zip',
 '/usr/lib/python3.5',
 '/usr/lib/python3.5/plat-x86_64-linux-gnu',
 '/usr/lib/python3.5/lib-dynload',
 '/home/steve/Documents/wger/venv-django/lib/python3.5/site-packages',
 '/home/steve/.config/wger']
Server time:    Mon, 24 Oct 2016 19:48:24 +0300
/home/steve/Documents/wger/wger-croners/wger/utils/language.py in load_language
    language = Language.objects.get(short_name=used_language) 

可能有什么不对?我遵循了Git自述文件的所有说明。

1 个答案:

答案 0 :(得分:1)

这是因为Language模型中没有short_name等于used_language的条目。有关详细信息,请参阅:Retrieve Object from Django Model

如果您想要short_hand创建used_language对象,如果找不到,请使用.get_or_create()代替:

 language, is_created = Language.objects.get_or_create(short_name=used_language)