title: ImportError : no module named 'models'
body: <p>The following code gives this error</p>
  
  <blockquote>
    <p>ImportError : no module named 'models'</p>
  </blockquote>
  
  <p>I don't know why. I am trying to customize my own registration form in django.</p>
  
  <p>The error is in line: </p>
  
  <pre><code>from models import CustomUser in forms.py 
  </code></pre>
  
  <p>forms.py:</p>
  
  <pre><code>from django.contrib.auth.forms import UserCreationForm, UserChangeForm
  
  from models import CustomUser
  
  class CustomUserCreationForm(UserCreationForm):
  
  def __init__(self, *args, **kargs):
      super(CustomUserCreationForm, self).__init__( *args, **kargs)
      del self.fields['username']
  
  class Meta:
      model = CustomUser
      fields = ["email",]
  
  class CustomUserChangeForm(UserChangeForm):
  
  def __init__(self, *args, **kargs):
      super(CustomUserChangeForm, self).__init__(*args, **kargs)
      del self.fields['username']
  
   class Meta:
      model = CustomUser
  </code></pre>
  
  <p>register.html :</p>
  
  <pre><code>{% extends "account/base.html" %}
  {% load crispy_forms_tags %}
   {% load i18n %}
  
  {% block head_title %}{% trans "Signup" %}{% endblock %}
  
  {% block content %}
  &lt;div class= 'col-md-4 col-md-offset-4'&gt;
  &lt;h1&gt;{% trans "Register" %}&lt;/h1&gt;
  
  &lt;p&gt;{% blocktrans %}Already have an account? Then please &lt;a href="{{   login_url }}"&gt;sign in&lt;/a&gt;.{% endblocktrans %}&lt;/p&gt;
  
  &lt;form acction="account/register/" method="post"&gt;
   {% csrf_token %}
   {{ form|crispy }}
  
  
   &lt;input type="submit" value="Register" /&gt;
   &lt;button type="submit" class= 'btn btn-default'&gt;{% trans "Sign Up" %} &amp;raquo;&lt;/button&gt;
  &lt;/form&gt;
   &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>views.py:</p>
  
  <pre><code>from django.contrib.auth.decorators import login_required
  from django.shortcuts import render, redirect 
  from custom_user.forms import CustomUserCreationForm
  
  #Create your views here
  def home(request):
      return render(request, "home.html")
  
  def login(request):
      c = {}
      c.update(csrf(request))
      return render(request, "login.html", c)
  
  def auth_view(request):
      username = request.POST.get['username', '']
      password = request.POST.get['password', '']
      user = auth.authenticate(username=username, password=password)
  
      if user is not None:
          auth.login(request, user)
          return HTTpResponseRedirect('account/login')
      else:
          return HTTpResponseRedirect('account/login')
  
  
  def logout(request):
      auth.logout(request)
      return render(request, 'logout.html')
  </code></pre>