ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Showing Validation Error like a popup,instead of loading another page in Django?

user-image
تم إضافة السؤال من قبل Hasan Zahran f
تاريخ النشر: 2017/04/16
fadi attya
من قبل fadi attya , TECHINICIAN , Mabna Holding Company

I use Djando :

class SignUpFormss (forms.ModelForm): class Meta: model = SignUp fields=['email','fullname']def clean_email(self): email=self.cleaned_data.get('email')if not "gmail" in email: raise forms.ValidationError("please enter gmail.com")return email

Mhadi Ahmed Ahmed
من قبل Mhadi Ahmed Ahmed , Backend Developer , dot.energy

use a client side validation like (jquery) or you can just use ajax request 

Ritto Thankankachan
من قبل Ritto Thankankachan , Software Developer , Fleming

ajax is the best option. most of the web sites are using this. 

Syed Faizun Nabi
من قبل Syed Faizun Nabi , Software Developer , Al Rumaithy

Use Ajax to poll the data and trigger the popup if the data is valid.

Using ajax with Django is as simple as any other platform, but only one thing to keep in mind is setting the XHR for csrf (in case of posting data).

$.ajax({

            type: "POST",

            data: "uid={{id}}",

            url: "your app url",

            beforeSend: function(xhr, settings){

                            xhr.setRequestHeader('X-CSRFToken','{{ csrf_token }}');

                          },

            success: function(data) {

              alert(data);

            }

        }); 

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟