If your model has the uniqueness constraint, you should get a form error message automatically. If you don't want your model to have that constraint but you still want your form to throw an error message, you can add a clean_<name of email field> and a clean_<name of mobile field> function that check for uniqueness and raise ValidationError if it fails (see examples here: https://docs.djangoproject.com/en/1.10/ref/forms/validation/ ).
When the form saves successfully, the user will be redirected to the success_url you provide. That template can have success message text. Alternately, in your form_valid function in the view, you could add a success message that will get added to whatever page you're redirecting to (as long as you make sure your template is rendering messages) -> https://docs.djangoproject.com/en/1.10/ref/contrib/messages/#adding-a-message On Mon, Oct 31, 2016 at 1:55 AM, pradam programming < [email protected]> wrote: > Hi, > Please I need an advice on the best approach to take on the following > issues. > I have create a form to save user details like first name,last > name,email,mobile number etc... > > 1.Now I need to show error message (In Models i gave email and mobile no > field as unique = True) when user enter a email id if email id exists in > database show message like email id exists beside the email text field(also > for the mobile no) else proceed with form. > 2.After i saving the form i need to show alert of success. > > regards, > Pradam Abhilash > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/django-users/CAGGVXBOz6kQs%2BHhR%2BsrTUApOGnR7t50HHQuvSN_ > zJz6VMQosFw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAGGVXBOz6kQs%2BHhR%2BsrTUApOGnR7t50HHQuvSN_zJz6VMQosFw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Andromeda Yelton Vice President/President-Elect, Library & Information Technology Association: http://www.lita.org http://andromedayelton.com @ThatAndromeda <http://twitter.com/ThatAndromeda> -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFE1XCbVpkpOboCKR_Xck-oTm2NJYCVQ6ssWZsBWRaNe3pQM9Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

