尝试运行函数时收到此错误.这是我的第一个django/python项目,所以我没有经验.我已经搜索过这个错误,但没有找到类似的东西.
def getpriority(chunks):
p = 0
for chunk in chunks:
a = chunk.result_set.all()
l = a.latest()
if pytz.utc.localize(datetime.now()) - l.timestamp > datetime.timedelta(days=3):
x = getresult(chunk)
print(x)
Run Code Online (Sandbox Code Playgroud)
我正在尝试为我的Chunk模型分配优先级,以便我可以选择具有最高优先级的Chunk来使用该对象.
我相信我的错误在于呼唤latest()'a'.
当我在django shell中运行Chunk.result_set.latest()时,我收到以下错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'ReverseManyToOneDescriptor' object has no attribute 'latest'
Run Code Online (Sandbox Code Playgroud)
在我的Result模型中,我设置了get_latest_by,我认为需要运行.latest():
class Result(models.Model):
rel_chunk = models.ForeignKey(Chunk, on_delete=models.CASCADE)
score = models.IntegerField()
timestamp = models.DateTimeField(auto_now_add=True)
class Meta:
get_latest_by = 'timestamp'
Run Code Online (Sandbox Code Playgroud)
我相信错误在于我在相关对象集上调用最新但如果无法在相关对象集上调用,那么如何才能找到最新的相关结果?
我一直在使用统一引擎构建一个英语游戏。我正在努力让 C# 解析 JSON。
过去几天我一直在尝试解析 JSON,但没有成功。我已经验证了 JSON,可以将 jsonString 调试到控制台,但是一旦 jsonUtility 拿到了 json,我就会得到一堆 NULL 数据。
这是我的json:
{"question": {"questionType": "0", "categoryID": "0", "bonusBool": "FALSE", "answerText": "cake", "questionText": "If something is really easy to do, it\u2019s a piece of \u2026\u2026\u2026 \\n a. pie \\n b. tart \\n c. cake", "ID": "0"}}
Run Code Online (Sandbox Code Playgroud)
这是我的 C#:
[System.Serializable]
public class QuestionDataAsString
{
public string questionText;
public string answerText;
public string categoryID;
public string ID;
public string questionType;
public string bonusBool;
}
[System.Serializable]
public class Question{
public string …Run Code Online (Sandbox Code Playgroud)