擅长:python、mysql、java
<p>您正在使用has_location自己的id筛选位置。必须使用<code>location_id</code>s筛选位置:</p>
<pre><code>user_haslocations = has_location.objects.filter(user_has=user)
locations = Location.objects.filter(id__in=user_haslocations.values('location_id'))
</code></pre>
<p>也可以通过反向关系直接过滤位置:</p>
<pre><code>location = Location.objects.filter(has_location__user_has=user.id)
</code></pre>