擅长:python、mysql、java
<p>不能在参数名中使用点,因此这部分<code>liquorID.BottleSize='750 ML'</code>会导致<code>SyntaxError</code></p>
<p>要在<code>filter</code>中使用相关模型,请使用跨越关系的查找</p>
<p><a href="https://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-span-relationships" rel="noreferrer">https://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-span-relationships</a></p>
<blockquote>
<p>Django offers a powerful and intuitive way to “follow” relationships in lookups, taking care of the SQL JOINs for you automatically, behind the scenes. To span a relationship, just use the field name of related fields across models, separated by double underscores, until you get to the field you want.</p>
</blockquote>
<p>所以你的陈述应该是这样的:</p>
<pre><code>StoreLiquor.objects.filter(storeID=ID_Store,
liquorID__BottleSize='750 ML',
custom=False).update(StorePrice=liquorID__ShelfPrice)
</code></pre>