Django-Registration and NewForms Error

509 views
Skip to first unread message

Chris

unread,
Oct 8, 2008, 7:37:42 AM10/8/08
to Django users
I installed django-registration via easy_install, and followed the
directions for setting it up in my app, but when I go to /register, I
get the error:

File "/usr/lib/python2.5/site-packages/django_registration-0.5-
py2.5.egg/registration/views.py", line 12, in <module>

File "/usr/lib/python2.5/site-packages/django_registration-0.5-
py2.5.egg/registration/forms.py", line 7, in <module>

ImportError: cannot import name newforms

Does anyone know what would cause this error? The line it's
complaining about is "from django import forms", which if I try from
the command line imports just fine.

This is the urls.py I'm using:

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from registration.views import activate
from registration.views import register

urlpatterns = patterns('',
(r'^account/activate/(?P<activation_key>\w+)/$',
activate,
{'template': 'templates/account_activate.html'}
),
(r'^account/login/$',
'django.contrib.auth.views.login',
{'template_name': 'templates/account_login.html'},
),
(r'^account/logout/$',
'django.contrib.auth.views.logout',
{'template_name': 'templates/account_logout.html'},
),
(r'^account/password/change/$',
'django.contrib.auth.views.password_change',
{'template_name': 'templates/account_password_change.html'}
),
(r'^account/password/change/done/$',
'django.contrib.auth.views.password_change_done',
{'template_name': 'templates/
account_password_change_done.html'}
),
(r'^account/password/reset/$',
'django.contrib.auth.views.password_reset',
{'template_name': 'templates/account_password_reset.html'}
),
(r'^account/password/reset/done/$',
'django.contrib.auth.views.password_reset_done',
{'template_name': 'templates/
account_password_reset_done.html'}
),
(r'^account/profile/$',
direct_to_template,
{'template': 'templates/account_profile.html'}
),
(r'^account/register/$',
register,
{'template': 'templates/account_register.html'},
),
(r'^account/register/complete/$',
direct_to_template,
{'template': 'templates/account_registration_complete.html'},
),
)

Rishabh Manocha

unread,
Oct 8, 2008, 7:58:50 AM10/8/08
to django...@googlegroups.com
The problem most probably is that the version of django-registration you have installed via easy_install is not the latest version available - and hence is probably doing an import like "from django import newforms as forms" (or something like that) in forms.py. "newforms" was renamed to "forms" at some point before the 1.0 release and so python is unable to import "newforms". The latest version(in trunk) seems to have fixed this[1].

Uninstall the version you have installed via easy_install and grab the latest tar from the official site - http://code.google.com/p/django-registration/.

--

Best,

R

[1] - http://code.google.com/p/django-registration/source/browse/trunk/registration/forms.py#7

Steve Holden

unread,
Oct 8, 2008, 6:37:31 PM10/8/08
to django...@googlegroups.com
Rishabh Manocha wrote:
> On Wed, Oct 8, 2008 at 5:07 PM, Chris <chri...@gmail.com
> <mailto:chri...@gmail.com>> wrote:
>
>
> I installed django-registration via easy_install, and followed the
> directions for setting it up in my app, but when I go to /register, I
> get the error:
>
> File "/usr/lib/python2.5/site-packages/django_registration-0.5-
> py2.5.egg/registration/views.py", line 12, in <module>
>
> File "/usr/lib/python2.5/site-packages/django_registration-0.5-
> py2.5.egg/registration/forms.py", line 7, in <module>
>
> ImportError: cannot import name newforms
> [...]

>
>
> The problem most probably is that the version of django-registration
> you have installed via easy_install is not the latest version
> available - and hence is probably doing an import like "from django
> import newforms as forms" (or something like that) in forms.py.
> "newforms" was renamed to "forms" at some point before the 1.0 release
> and so python is unable to import "newforms". The latest version(in
> trunk) seems to have fixed this[1].
>
> Uninstall the version you have installed via easy_install and grab the
> latest tar from the official site -
> http://code.google.com/p/django-registration/.
>
I believe I installed from SVN quite recently and discovered that
newforms was still used. James Bennet recently pointed out he hadn't yet
had time to 1.0-ify all his contributions. The only change i had to make
was changing

import newforms as forms

to

import forms

regards
Steve

Chris Spencer

unread,
Oct 8, 2008, 8:51:21 PM10/8/08
to django...@googlegroups.com
Thanks guys, that fixed the problem.
Reply all
Reply to author
Forward
0 new messages