title: django - how to check if email is already exists
body: <p>I need to show error message if email is already exists, but I can't check if new customer trying to enter used email.</p>
  <p>I am using UserChangeForm.</p>
  <p>forms.py</p>
  <pre><code>class UserChangeForm(forms.ModelForm):
  
      class Meta:
          model = Account
          fields = ('email', 'fname', 'lname', 'phone','bday', 'country', 'gender','picture')
          
      email = forms.CharField(widget=forms.EmailInput(attrs={'class':'form-control'}))
      phone = PhoneNumberField(widget=PhoneNumberPrefixWidget(initial='GE'), required=False)
      phone.error_messages['invalid'] = 'Incorrect international code or Phone number!'    
  
  
      
      
      def clean_password(self):
          return self.initial[&quot;password&quot;]
  </code></pre>
  <p>views.py</p>
  <pre><code>@login_required
  def edit_profile(request, id):
      account = Account.objects.all()
      user = Account.objects.get(id=id)
      form = UserChangeForm(instance=user)
  
      if request.method == &quot;POST&quot;:
          form = UserChangeForm(request.POST, files=request.FILES, instance=user)
          for info in account:
              if info.email == form.email:
                  messages.warning(request, 'email already exists.')
          if form.is_valid():
              data = form.save(commit=False)
              data.is_active = True
              data.save()
  
              return redirect('account:editprofile', id)
  
      context = {'form':form, 'user':user}
      return render(request, 'edit_profile.html', context)
  </code></pre>
  <p>html</p>
  <pre><code>&lt;div class=&quot;form-div-container&quot;&gt;
       &lt;label class=&quot;label label-padding&quot;&gt;Email&lt;/label&gt;
       {% render_field form.email class=&quot;form-control form-control-edit&quot; %}
  &lt;/div&gt;
  {% if messages %}
       {% for message in messages %}
             &lt;div class=&quot;alert alert-info display-flex align-items-center for-alert&quot; role=&quot;alert&quot;&gt;
                  &lt;p class=&quot;alert-p&quot;&gt;&lt;/p&gt;{{ message }}&lt;/p&gt;
             &lt;/div&gt;
       {% endfor %}
   {% endif %}
  </code></pre>
  <p>I saw some examples but they don't work in my case as I do.</p>
  <p>Also, I find out form.errors but I didn't like it.</p>
  <p>I tried my way in views but it didn't work also</p>
  <p>So, I hope you will help me.</p>