Registration Form import error
Question: I am following DjangoBook tutorial and i have encountered a problem on chapter
14 ( User Registration )

In _django.contrib.auth.forms_ , there is a `UserCreationForm` class. I am
trying to create a new class based on `UserCreationForm` called `RegisterForm`

This is my class `RegisterForm` in _django.contrib.auth.forms_

    
    
    class RegisterForm(UserCreationForm):
        email = forms.EmailField(label="Email")
        fullname = forms.CharField(label="Full name")
    
        class Meta:
            model= User
            fields = ("username","fullname","email",)
    

This is the view function

    
    
    def register(request):
        if request.method == 'POST':
            form = UserCreationForm(request.POST)
            if form.is_valid():
                new_user = form.save()
                return HttpResponseRedirect("/books/")
        else:
            form = RegisterForm(UserCreationForm)
        return render(request, "registration/register.html", {
            'form': form,
        })
    

I have no idea why i am getting a ImportError which states that I cannot
import name `RegisterForm` in my view , can someone help me out thanks.

This is my stack trace

    
    
    Environment:
    
    
    Request Method: GET
    Request URL: http://127.0.0.1:8000/register/
    
    Django Version: 1.5.1
    Python Version: 2.7.2
    Installed Applications:
    ('django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'mysite.books')
    Installed Middleware:
     ('django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware')
    
    
    Traceback:
    File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
    103.                     resolver_match = resolver.resolve(request.path_info)
    File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in resolve
    319.             for pattern in self.url_patterns:
    File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in url_patterns
    347.         patterns = getattr(self.urlconf_module, "urlpatterns",                      self.urlconf_module)
    File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in urlconf_module
    342.             self._urlconf_module = import_module(self.urlconf_name)
    File "C:\Python27\lib\site-packages\django\utils\importlib.py" in import_module
    35.     __import__(name)
    File "C:\Users\Ray Lim\Desktop\project\home\username\djcode\mysite\mysite\urls.py" in    <module>
    14. from mysite.books import views
    File "C:\Users\Ray    Lim\Desktop\project\home\username\djcode\mysite\mysite\books\views.py" in <module>
    11. from django.contrib.auth.forms import RegisterForm
    
    Exception Type: ImportError at /register/
    Exception Value: cannot import name RegisterForm
    


Answer: As of **Django 1.5** there is no such form in the module
`django.contrib.auth.forms.`

You might want to use an editor that would highlight such things for you. Such
as [PyCharm](https://www.jetbrains.com/pycharm/).

Still, point stands, you should have at least basic understanding of `Python`
to learn `Django`. You see, the statements

    
    
    class RegisterForm(UserCreationForm)    
        ...
    # And then:
    form = RegisterForm(UserCreationForm) 
    

Hardly make any sense from Python perspective.

You are writing Python code. In Python. You'll have to learn Python. Yes, it
is possible to go another way, but it is much harder.

