我想只允许超级用户访问html文件。 只是{%if user.is_authenticated%}如何验证包括超级用户在内的所有用户,我有什么办法只能验证超级用户而不验证非超级用户?
{% block title %}base{% endblock %}
{% block content %}
{% if user.is_authenticated %}
{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% block title %}Django{% endblock %}</title>
</head>
<body>
<main>
{% block content %}
{% endblock %}
</main>
</body>
</html>
{% else %}
<p>You are not logged in</p>
<a href="{% url 'login' %}">login</a>
{% endif %}
{% endblock %}
答案 0 :(得分:0)
{% if user.is_authenticated and user.is_superuser %}
如果用户是超级用户并经过验证,则应该返回True。
答案 1 :(得分:0)
$this->dbType = 'pdo_mysql';
$this->dbCharset = 'utf8';
$this->dbHost = 'localhost'; // database host name
$this->dbPort = 3306; // tcp port to which the database is bound
$this->dbName = 'xxxxx'; // database name
$this->dbUser = 'xxxxx'; // database user name
$this->dbPwd = 'xxxxx'; // database user password
$this->dbDriverOptions = []; // database driver options
$this->dbUnixSocket = null; // unix domain socket, optional
$this->sShopURL = 'https://www.mela.kalamulur.com'; // eShop base url, required
$this->sSSLShopURL = null; // eShop SSL url, optional
$this->sAdminSSLURL = null; // eShop Admin SSL url, optional
$this->sShopDir = '/var/www/html/mela/source';
$this->sCompileDir = '/var/www/html/mela/source/tmp';