【问题标题】:CSS definitions in django-allauth account templatesdjango-allauth 帐户模板中的 CSS 定义
【发布时间】:2020-07-27 01:33:25
【问题描述】:

我正在试用 django-allauth,并且在自定义 allauth 帐户模板时遇到了障碍。我目前正在处理 emails.html 模板,但我找不到默认模板中使用的 css 类的任何定义。

CSS 分类,例如 ctrlHolder 或 primary_email。请帮我弄清楚这些是在哪里定义的。我可以使用引导 css,但如果它们足够好,我希望保留默认的 css。

accounts/emails.html

{% extends "account/base.html" %}

{% load i18n %}

{% block head_title %}{% trans "E-mail Addresses" %}{% endblock %}

{% block content %}
    <h1>{% trans "E-mail Addresses" %}</h1>
    {% if user.emailaddress_set.all %}
        <p>{% trans 'The following e-mail addresses are associated with your account:' %}</p>

        <form action="{% url 'account_email' %}" method="post">
            {% csrf_token %}
            <div class="form-group">

                {% for emailaddress in user.emailaddress_set.all %}
                    <div class="ctrlHolder">
                        <label for="email_radio_{{ forloop.counter }}"
                               class="{% if emailaddress.primary %}primary_email{% endif %}">

                            <input id="email_radio_{{ forloop.counter }}" type="radio" name="email"
                                   {% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked"{% endif %}
                                   value="{{ emailaddress.email }}"/>

                            {{ emailaddress.email }}
                            {% if emailaddress.verified %}
                                <span class="verified">{% trans "Verified" %}</span>
                            {% else %}
                                <span class="unverified">{% trans "Unverified" %}</span>
                            {% endif %}
                            {% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %}
                        </label>
                    </div>
                {% endfor %}

                <div class="buttonHolder">
                    <button class="secondaryAction" type="submit"
                            name="action_primary">{% trans 'Make Primary' %}</button>
                    <button class="secondaryAction" type="submit"
                            name="action_send">{% trans 'Re-send Verification' %}</button>
                    <button class="primaryAction" type="submit" name="action_remove">{% trans 'Remove' %}</button>
                </div>

            </div>
        </form>

    {% else %}
        <p>
            <strong>{% trans 'Warning:' %}</strong> {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}
        </p>

    {% endif %}


    <h2>{% trans "Add E-mail Address" %}</h2>

    <form method="post" action="{% url 'account_email' %}" class="add_email">
        {% csrf_token %}
        {{ form.as_p }}
        <button name="action_add" type="submit">{% trans "Add E-mail" %}</button>
    </form>

{% endblock %}


{% block extra_body %}
    <script type="text/javascript">
        (function () {
            var message = "{% trans 'Do you really want to remove the selected e-mail address?' %}";
            var actions = document.getElementsByName('action_remove');
            if (actions.length) {
                actions[0].addEventListener("click", function (e) {
                    if (!confirm(message)) {
                        e.preventDefault();
                    }
                });
            }
        })();
    </script>
{% endblock %}

在这里,我通过帐户 base.html 调用了我的自定义基本页面

{% extends "shared/base.html" %}

【问题讨论】:

    标签: django django-allauth


    【解决方案1】:

    该类未在 allauth 中定义。它在那里,以便您可以在 CSS 中定义它。我猜名称是 ctrlHolder 和 buttonHolder 因为它们是 input-control 和 button html 语句的占位符类名称。

    【讨论】:

    • 谢谢。认为这样。我已经使用自定义 js 和 css 与 django 的块系统在特定页面插入所需的分类!
    猜你喜欢
    • 2020-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-11
    • 2013-12-27
    • 2013-09-22
    相关资源
    最近更新 更多