代码之家  ›  专栏  ›  技术社区  ›  GeniusBehind

编辑配置文件在Django中为我提供了算法、迭代和哈希

  •  0
  • GeniusBehind  · 技术社区  · 7 年前

    当我进入“编辑个人资料”页面时,它看起来是这样的:

    enter image description here

    class EditProfileForm(UserChangeForm):
        template_name='/something/else'
    
        class Meta:
            model = User
            fields = (
                'email',
                'first_name',
                'last_name',
                **'password'**
            )
    


    它向我展示了:

    enter image description here

    请随意分享您的想法。

    1 回复  |  直到 7 年前
        1
  •  1
  •   GeniusBehind    7 年前

    我更改了代码表单。py到edit_profile中的可编辑代码。html(采用forms.py中的条目):

    编辑_配置文件。html:

    <form method="post">
        {% csrf_token %}
    
        <label for="first_name">Vorname </label>
        <input style="margin-bottom: 1em;" id="first_name" class="form-control" type="text" maxlength="25" name="first_name" value="{{ user.first_name }}"><br>
        <label for="last_name">Nachname </label>
        <input style=" margin-bottom: 1em;" id="last_name" class="form-control" type="text" maxlength="25" name="last_name" value="{{ user.last_name }}"><br>
        <label for="email">E-Mail </label>
        <input style="margin-bottom: 1em;" id="email" class="form-control" type="email" maxlength="50" required=True unique=True name="email" value="{{ user.email }}"><br>
    
        <button class="btn btn-success btn-sm" type="submit">Bestätigen</button>
        <a style="margin-left: 1em;" href="{% url 'accounts:view_profile' %}" id="cancel" name="cancel" class="btn btn-default">Zurück</button></a>
    
        {% if form.errors %}
          <p style="margin-left: 5em;" class=" label label-danger">
              Das ist keine gültige E-Mail-Adresse. Bitte versuche Sie es erneut.
          </p>
        {% endif %}
    
    </form>