I'm trying to use django-registration in my project, and I have to add two extra fields in registration form. My django version is 1.6.2 and python 2.7.
My urls.py
:
from django.conf.urls import patterns, include, url
from registration.views import RegistrationView
from common.forms import UserRegistrationForm
import common.regbackend
urlpatterns = patterns('',
# accounts
url(r'^accounts/register/$', RegistrationView.as_view(form_class=UserRegistrationForm),
{'backend': 'user_profile.backends.RegistrationBackend'},
name='registration_register'),
url(r'^accounts/', include('registration.backends.default.urls')),
# home
url(r'^$', 'home.views.home', name='home'),
)
My common/models.py
:
from django.db import models
class Profile(models.Model):
key = models.CharField(max_length=100)
code = models.CharField(max_length=100)
def __unicode__(self):
return '%s' % self.key
class Meta:
ordering = ['key']
verbose_name = "Profile"
verbose_name_plural = "Profiles"
My common/forms.py
:
from django import forms
from registration.forms import RegistrationForm
class UserRegistrationForm(RegistrationForm):
key = forms.CharField(label='Key')
code = forms.CharField(label='VCode')
And finally, common/regbackend.py
from forms import *
from models import Profile
from common.forms import UserRegistrationForm
def user_created(sender, user, request, **kwargs):
print 'ok' # breakpoint here!
return
'''
form = UserRegistrationForm(request.POST)
data = Profile(user=user)
data.key = form.data["key"]
data.code = form.data["code"]
data.save()
'''
from registration.signals import user_registered
user_registered.connect(user_created)
When I fill up the form and try to send it I get
NotImplementedError at /accounts/register/
and my app never stops at the breakpoint in common/regbackend.py
file.
The traceback ends up here:
/Users/null/.virtualenvs/tools/lib/python2.7/site-packages/registration/views.py in register
in this function:
def register(self, request, **cleaned_data):
"""
Implement user-registration logic here. Access to both the
request and the full cleaned_data of the registration form is
available here.
"""
raise NotImplementedError
I have tried to search for solution (especially this, this and this) but most of them are using django-registration 0.8 and I'm using v1.0 which is completely rewritten and some things are not working as they used to. I have tried to adjust it for v1.0 but still getting this error.
What should I do to get rid of this error? Thanks in advance!