validationerror

struts2 validation using message store interceptor

笑着哭i 提交于 2019-11-28 14:26:06
consider this: user clicks on a link request goes to DisplayLoginAction Login.jsp is displayed user enters his credentials form is mapped to ValidateLoginAction validation fails in ValidateLoginAction ValidateLoginAction stores the errors and returns "input" redirecting to DisplayLoginAction.. DisplayLoginAction retrieves the errors from the interceptor and shows them to the user above the login form user refreshes the page The errors are gone How should I save the errors on page refresh? <action name="displayLoginPage" class="DisplayLoginAction"> <interceptor-ref name="store"> <param name=

Django, show ValidationError in template

孤者浪人 提交于 2019-11-27 19:08:30
I create a registation app, where users can register providing a username, email and a password. What I did is make sure that the email field is unique(as you can see in the code below). But I can't figure out how I can show the error in case the a user enters an email address that is already in use. View from django.shortcuts import render from django.shortcuts import render_to_response from django.http import HttpResponseRedirect from django.core.context_processors import csrf from forms import RegistrationForm # Create your views here. def register_user(request): if request.method == 'POST'

Raise a validation error in a model's save method in Django

≡放荡痞女 提交于 2019-11-27 06:39:50
I'm not sure how to properly raise a validation error in a model's save method and send back a clear message to the user. Basically I want to know how each part of the "if" should end, the one where I want to raise the error and the one where it actually saves: def save(self, *args, **kwargs): if not good_enough_to_be_saved: raise ValidationError else: super(Model, self).save(*args, **kwargs) Then I want to know what to do to send a validation error that says exactly to the user what's wrong just like the one Django automatically returns if for example a value is not unique. I'm using a

Raise a validation error in a model&#39;s save method in Django

余生颓废 提交于 2019-11-26 10:27:41
问题 I\'m not sure how to properly raise a validation error in a model\'s save method and send back a clear message to the user. Basically I want to know how each part of the \"if\" should end, the one where I want to raise the error and the one where it actually saves: def save(self, *args, **kwargs): if not good_enough_to_be_saved: raise ValidationError else: super(Model, self).save(*args, **kwargs) Then I want to know what to do to send a validation error that says exactly to the user what\'s