Hi All,
Kindly help me with following questions.
         
Use case is this:
1. i have created a form manually ( not generated through django forms)
2. I am calling a Django view function upon submission.
3. validating the field through django form as i ensured that form names 
are same.

question is
1. How to pass on validation errors from Djnago form to non django forms?
Please suggest better ways to do this.

Note. I see one way is to jsonify the errors and reconstruct the DOM


Let me take an example.
I do not want to use Djnago generated form hence i have written my own 
login page:

*<div class="col-md-4 col-md-offset-4" id="id_loginform">*

*    <h3>Login to Application</h3>*

*    <form class="form-horizontal" method="POST" action={% url "auth_login" 
%}  > {% csrf_token %}*

*        <div class="form-group">*

*            <div class="input-group">*

*              <div class="input-group-addon" id="id_username" 
name="username" >User ID  </div>*

*              <input type="text" class="form-control" id="username" name 
="username" placeholder="User name">*

*            </div>*

*             <div class="input-group">*

*              <div class="input-group-addon">Password </div>*

*              <input type="password" class="form-control" name="password" 
id="password" placeholder="Password">*

*              </div>*

*            </div>*

  *            <div class="col-md-offset-4 col-md-8">*

*                <button type="submit" class="btn btn-default">Sign 
in</button>*

*            </div>*

*        </div>*

      *</form>*

*</div> *
      
action is passed to view where i am trying to do this.

  def login_view(request):

    if request.POST:

        form = LoginForm(request.POST or None)

        if form.is_valid():

            username = form.cleaned_data['username']

            password = form.cleaned_data['password']

            user = authenticate(username=username, password=password)

            login(request, user)

            return HttpResponseRedirect(reverse("menu"))

    else:

        form = LoginForm()

      context = {"form": form,}
    return render(request, "login.html", context)  

*when ther are form eeors invalid user id or pasword......waht is the way 
to pass valiadtion errors to "UNBOUND Form".*
*I personally see only way to return jason response and process it on 
unbound form?....is there anyway djnago can directly pass validation errors 
to forms that are not created by djnago?*


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6f74d6f9-1c29-4ce7-b2df-4f74b8fefb05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to