|
# application.forms |
|
# I'm assuming that you'd want to play with the forms too. |
|
|
|
from django import forms |
|
from registration.forms import RegistrationFormUniqueEmail |
|
from socialregistration.forms import UserForm |
|
|
|
class NormalRegistrationForm(RegistrationFormUniqueEmail): |
|
first_name = forms.CharField() |
|
last_name = forms.CharField() |
|
|
|
class SocialRegistrationForm(UserForm, NormalRegistrationForm): |
|
""" Extending the above form to include some fields in this form too """ |
|
def __init__(self, *args, **kwargs): |
|
super(SocialRegistrationForm, self).__init__(*args, **kwargs) |
|
# Social users dont need passwords, so this form doesn't need these fields |
|
del self.fields['password1'] |
|
del self.fields['password2'] |
|
|
|
# You might want to prepopulate some fields here with information from |
|
# Facebook or whatever |
|
# from django_globals import globals |
|
# -> http://code.google.com/p/django-globals/source/browse/trunk/django_globals/__init__.py |
|
# uid = globals.request.facebook.uid |
|
# data = globals.request.facebook.users.getInfo([uid],['first_name','last_name'])[0] |
|
# self.inital['first_name'], self.initial['last_name'] = data['first_name'],data['last_name'] |
|
|
|
# application.urls |
|
from django.conf.urls.defaults import * |
|
from application.forms import NormalRegistrationForm, SocialRegistrationForm |
|
|
|
urlpatterns = patterns('', |
|
|
|
# We're first overriding the registration url to pass in our own form |
|
url('^registration/register/$', 'registration.views.register', dict( |
|
form_class = NormalRegistrationForm, template_name = 'application/custom_registration_form.html'), |
|
name = 'registration_register') |
|
# Now we include the registration urls |
|
url('^registration/', include('registration.urls')), |
|
|
|
# Now we're doing the same with socialregistration |
|
url('^social/setup/$', 'socialregistration.views.setup', dict( |
|
form_class = SocialRegistrationForm, template = 'application/custom_registration_form.html'), |
|
name = 'socialregistration_setup') |
|
url('^social/', include('socialregistration.urls')), |
|
) |