擅长:python、mysql、java
<p>在大多数情况下,您不希望处理不存在这样的对象。而不是</p>
<pre><code>ad[0].id
</code></pre>
<p>使用</p>
<pre><code>get_object_or_404(AttachedInfo, attachedMarker=m.id, title=title)
</code></pre>
<p>为此,建议使用<a href="https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#get-object-or-404" rel="nofollow noreferrer">Django shortcut</a>。</p>