<p>您已获取用户对指定对象的权限</p>
<pre><code>{% get_obj_perms request.user for resource.layer as "layer_perms" %}
</code></pre>
<p>但您尚未使用从此行获得的权限。因此,您需要检查用户是否拥有层对象的权限(例如can\u view、can\u download等)。你知道吗</p>
<p>您可以将代码更改为:</p>
<pre><code>{% if resource.storeType != "remoteStore" %}
{% get_obj_perms request.user for resource.layer as "layer_perms" %}
<li class="list-group-item">
{% if links or links_download %}
{% if "can_download" in layer_perms %} # change here, check if user has required permissions
<button class="btn btn-primary btn-md btn-block" data-toggle="modal" data-target="#download-layer">{% trans "Download Layer" %}</button>
{% endif %} # close the condition
{% else %}
{% if request.user.is_authenticated %}
<button class="btn btn-primary btn-md btn-block" id="request-download">{% trans "Request Download" %}</button>
{% endif %}
{% endif %}
</li>
{% endif %}
</code></pre>
<p>确保您根据您的要求更改代码。你知道吗</p>
<p>为了进一步的参考,您可以看看<a href="https://django-guardian.readthedocs.io/en/stable/api/guardian.templatetags.guardian_tags.html" rel="nofollow noreferrer">guardian-template-tags</a></p>