Raw View class without form and model

17 views
Skip to first unread message

Tal Bar-Or

unread,
Feb 17, 2021, 8:01:39 AM2/17/21
to Django users

Hello ,

I would like to write Raw view model for current scenario,

i started writing portal for self service AD change password , the view for the change password is no need any model ,since it should be is using background ldap3 library , in addition i would like in a POST method to read the HTML name tag for current password and new password without need of form

i started to build the view class , but seems i am missing something, if someone can assist me will be appreciated.

Thanks

view class

class ChangeUserPassword(View):
    info_sended = False
    template_name = "changepassword.html"
    AUTH_SERVER = config('AUTH_SERVER')
    BASEDN = config('BASEDN')
    #form_class = UserChangePasswordForm
    #success_url = reverse_lazy('loader_success')

    def get(selfrequest):
        current_user = request.user
        context = {'form' : current_user}
        return render(request, self.template_name, context)

    def post(selfrequest):
        PassForm = ""
        #form = PassForm()
        if request.method == 'POST':
            form = PassForm(request.POST)

            if form.is_valid():
                current_user = request.user
                print(current_user)

HTML form

<div class="login-or">
            
          </div>
          
          <div class="form-group">
            
            <form id="login-nav" method="post" role="form" class="form" accept-charset="UTF-8">
            {% csrf_token %}


              <!-- Current-Password group -->
              <div class="form-group">

                <!-- Current-Password label -->
                <label class="sr-only">Current Password </label>
                <!-- Current-Password input -->
                <div class="input-group">
                  <input type="password" id="cuInput" class="form-control" data-placement="bottom" 
          data-toggle="popover" data-container="body" data-html="true" placeholder="Current Password" required>

                  <div class="input-group-append">
                    <button class="btn btn-outline-secondary" type="button" id="" onclick="CurrentPass()">
                      <i class="fa fa-eye" aria-hidden="true"></i>
                    </button>
                  </div>
                  
                </div>
                <!-- password-confirm error message -->
                <div class="help-block text-right">
                  <small><span id="" class="hide pull-right block-help">
                  <i class="fa fa-info-circle text-danger" aria-hidden="true"></i>Don't match password'</span></small>
                </div>

              </div>
              <hr class="hr-or">
              
            </div>
              <!-- password group -->
              <div class="form-group">
                
                <!-- password label -->
                <label class="sr-only">Password</label>
                <!-- password input -->
                <div class="input-group">
                  <input type="password" id="reg_userpassword" name="user_password" class="form-control" data-placement="bottom" data-toggle="popover" data-container="body"
          data-html="true" value="" placeholder="Password" required>

                  <div class="input-group-append">
                    <button class="btn btn-outline-secondary" type="button" id="button-append1" onclick="togglePassword()">
                      <i class="fa fa-eye" aria-hidden="true"></i>
                    </button>
                  </div>
                </div>
Reply all
Reply to author
Forward
0 new messages