title: Django - Update User instance by form
body: <h1>Befor all :</h1>
  <p><strong>Djano VERSION = 1.8</strong>, and  it's obligatory that I use this version</p>
  <h1>Question</h1>
  <p>I do not know why I cannot update the User instance by a form.</p>
  <p>I mean by updating: changing the value in the database and in the request</p>
  <p>The User model is not created by me but I use django.contrib.auth.models.User</p>
  <h1>Code</h1>
  <p>This is my code</p>
  <p>app/forms.py</p>
  <pre><code>from django import forms
  from django.contrib.auth.models import User
  
  class ModificationForm(forms.ModelForm):
      class Meta:
          model = User
          fields = ['email']
  </code></pre>
  <p>app/views.py</p>
  <pre><code>from django.contrib.auth.decorators import login_required
  from django.shortcuts import render
  from app.forms import ModificationForm
  
  
  @login_required
  def profil(request):
      if request.method == &quot;POST&quot;:
      form = ModificationForm(data=request.POST, instance=request.user)
      if form.is_valid():
          form.save()
      else:
          form = ModificationForm()
  
      return render(request, &quot;profil.html&quot;, {'form':form})
  </code></pre>
  <p>profile.html</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
      &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;Profil&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Profil&lt;/h1&gt;
          &lt;a href='/deconnexion'&gt; Logout &lt;/a&gt;
          &lt;form method=&quot;post&quot; action=&quot;.&quot;&gt;
             {% csrf_token %}
             {{ form.as_p }}
             &lt;input type=&quot;submit&quot; value=&quot;Enregistrer&quot; /&gt;
         &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>