I looked at my code in order to notice diffs.

You should add return new_user() after your new_profile.save()


On Mon, Mar 5, 2012 at 11:54 AM, Stanwin Siow <stanwin.kts...@gmail.com>wrote:

> Greetings,
>
> How do i save a user's profile into the database once i entered the
> details in my custom registration form?
>
> Also right now when i'm testing it out, i get the following error:
>
> create_inactive_user() got an unexpected keyword argument 'profile_callback'
>
> What could be the problem here?
>
> Am i overriding the original form correctly?
>
> Appreciate any inputs. Cheers
>
> here are the snippets you require:
>
> *Forms.py*
> *
> *
> from django import forms
> from r2.models import Keyword
> from r2.models import UserProfile
> from registration.forms import RegistrationForm
> from registration.models import RegistrationProfile
> from django.utils.translation import ugettext_lazy as _
> from registration.forms import RegistrationForm, attrs_dict
>
> class ProjectSpecificRegistrationForm(RegistrationForm):
>     keywords = forms.ModelChoiceField(queryset=Keyword.objects.all())
>     first_name
> =forms.CharField(widget=forms.TextInput(attrs=attrs_dict),label=_(u'First
> Name'))
>     last_name
> =forms.CharField(widget=forms.TextInput(attrs=attrs_dict),label=_(u'Last
> Name'))
>
> def save(self):
>     new_user =
> RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],
>     password=self.cleaned_data['password1'],
>     email=self.cleaned_data['email'])
>     new_profile =
> UserProfile(user=new_user,username=self.cleaned_data['username'],
> keywords_subscribed=self.cleaned_data['keywords'],first_name=self.cleaned_data['first_name'],last_name=self.cleaned_data['last_name'])
>
>     new_profile.save()
>
> *project urls.py*
>
> from r2.registration.views import activate
> from r2.registration.views import register
> from r2.forms import ProjectSpecificRegistrationForm
>
>     url(r'^accounts/', include('registration.urls')),
>     #url(r'^accounts/profile/', 'r2.views.profile'),
>     url(r'^keyword_subscribe/$', 'r2.views.keyword_subscribe'),
>     url(r'^refresh_list/$', 'r2.views.refresh_list'),
>     url(r'^test/$', 'r2.views.test'),
>
>     #registrations URLS
>
> url(r'^activate/(?P<activation_key>\w+)/$',activate,name='registration_activate'),
>     url(r'^login/$',auth_views.login,{'template_name':
> 'registration/login.html'}, name='auth_login'),
>     url(r'^logout/$',auth_views.logout,{'template_name':
> 'registration/logout.html'},name='auth_logout'),
>
> url(r'^password/change/$',auth_views.password_change,name='auth_password_change'),
>
> url(r'^password/change/done/$',auth_views.password_change_done,name='auth_password_change_done'),
>
> url(r'^password/reset/$',auth_views.password_reset,name='auth_password_reset'),
>
> url(r'^password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',auth_views.password_reset_confirm,name='auth_password_reset_confirm'),
>
> url(r'^password/reset/complete/$',auth_views.password_reset_complete,name='auth_password_reset_complete'),
>
> url(r'^password/reset/done/$',auth_views.password_reset_done,name='auth_password_reset_done'),
>     url(r'^register/$',register, {'form_class' :
> ProjectSpecificRegistrationForm},  name='registration_register'),
>
>     url(r'^register/complete/$',direct_to_template,{'template':
> 'registration/registration_complete.html'},name='registration_complete'),
>
>
>
>
> Best Regards,
>
> Stanwin Siow
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to