Thanks and i tried to do in same fashion as Bennett suggested
but getting errror

def register_handle_form(request, redirect=None):

    print "I am in handle form"
    form_class = utils.get_profile_form()
    if request.method == 'POST':
        print "i am in profile post"
        profileform = form_class(data=request.POST,
files=request.FILES)
        form = RegistrationForm(request.POST)
        if form.is_valid():
            contact = form.save(request)
            profile_obj = profileform.save(commit=False)
            profile_obj.user = request.user
            profile_obj.save()
            if not redirect:
                redirect = urlresolvers.reverse
('registration_complete')
            return (True, http.HttpResponseRedirect
(urlresolvers.reverse('registration_complete')))
            #return HttpResponseRedirect(reverse
('registration_complete'))

    else:
        initial_data = {}
        try:
            contact = Contact.objects.from_request(request,
create=False)
            initial_data = {
                'email': contact.email,
                'first_name': contact.first_name,
                'last_name': contact.last_name }
        except Contact.DoesNotExist:
            log.debug("No contact in request")
            contact = None

        signals.satchmo_registration_initialdata.send(contact,
            contact=contact,
            initial_data=initial_data)

        form = RegistrationForm(initial=initial_data)
        profileform = form_class(data=request.POST,
files=request.FILES)
    return (False, form, profileform)



def activate(request, activation_key):
    from registration.models import RegistrationProfile
    activation_key = activation_key.lower()
    account = RegistrationProfile.objects.activate_user
(activation_key)

    if account:
        # ** hack for logging in the user **
        # when the login form is posted, user = authenticate
(username=data['username'], password=data['password'])
        # ...but we cannot authenticate without password... so we work-
around authentication
        account.backend = settings.AUTHENTICATION_BACKENDS[0]
        login(request, account)
        contact = Contact.objects.get(user=account)
        request.session[CUSTOMER_ID] = contact.id
        send_welcome_email(contact.email, contact.first_name,
contact.last_name)
        signals.satchmo_registration_verified.send(contact,
contact=contact)

    context = RequestContext(request, {
        'account': account,
        'expiration_days': config_value('SHOP',
'ACCOUNT_ACTIVATION_DAYS'),
    })
    return render_to_response('registration/activate.html', context)


def register(request, redirect=None, template='registration/
registration_form.html'):
    """
    Allows a new user to register an account.
    """
    print " I am in my register"
    ret = register_handle_form(request, redirect)
    #ret = register_handle_profile_form(request, redirect)
    #form_class = utils.get_profile_form()
    #pform = form_class(data=request.POST, files=request.FILES)
    print "Ret length :", len(ret)
    print "Ret :", ret
    #print "Pet :", pform
    success = ret[0]
    todo = ret[1]
    profiledo = ret[2]
    #print "Profile object :", profiledo
    if len(ret) > 2:
        extra_context = ret[2]
        #print "If extra context", extra_context
    else:
        extra_context = {}
        #print "Else extra context", extra_context

    if success:
        return "Successfull"
    else:
        if config_get_group('NEWSLETTER'):
            show_newsletter = True
        else:
            show_newsletter = False

        ctx = {
            'form': todo,
            'pform': profiledo,
            'title' : _('Registration Form'),
            'show_newsletter' : show_newsletter
        }
        print "CTX :", ctx
        #if extra_context:
         #   ctx.update(extra_context)

        context = RequestContext(request, ctx)
        return render_to_response(template, context)

ERROR:
tuple index out of range

    profiledo = ret[2]  //in this line
when i go to accounts/register/ at first time and tried to print the
ret
Ret : (False, <foodies.foodapp.forms.RegistrationForm object at
0x914df4c>, <profiles.utils._ProfileForm object at 0x9162f8c>) it
returns me a tuple with 3 elements after clicking on register button
it return me tuple with 2 elements.


On Apr 9, 11:50 am, James Bennett <ubernost...@gmail.com> wrote:
> On Thu, Apr 9, 2009 at 12:27 AM, Praveen <praveen.python.pl...@gmail.com> 
> wrote:
> > Thank you so much Malcolm but to display extra fields on sign up we
> > will have to customize the django.contric.auth.forms then that form is
> > generated from the user models i am so much confused whether i will
> > have to add extra field in user model class or not but i do not want
> > change the structure of auth_user table. ok in a single line i want
> > django-registration and django-profile to be mingle in one form. could
> > you please suggest me link or idea.
>
> So you need to provide:
>
> 1. A form class which has all the fields you care about, and
> 2. A 'save()' method on instances of that form class which will create
> save the objects you want to have saved.
>
> The first step is easy; you just set out writing a form like any other.
>
> The second step is similarly easy; since you're the one writing the
> form class, you know what fields the form has, and you know which
> correspond to the user and which correspond to the profile. So read
> the appropriate data from the form's cleaned_data for the user, create
> and save a User object, then read the appropriate data from
> cleaned_data for the profile, create and save a profile object. And
> then you're done.
>
> So I guess I'm a bit confused as to what's so hard here; this is
> really quite basic everyday Python programming, not any kind of deep
> magic.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~---------~--~----~------------~-------~--~----~
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