Userena, how to set the avatar (mugshot) at signup time?

165 views
Skip to first unread message

Bastian

unread,
Sep 12, 2012, 6:20:45 AM9/12/12
to django...@googlegroups.com
Hello,

I use userena to manage signups and profiles. It works fine and users can set up their avatar in the profile but I'd like them to set it up during signup time. When they register they need to fill username, email, password and sometimes other basic stuffs needed to create a user account. I'd like to add the avatar (mugshot) to that list. What would be the way to go?

I am trying to inherit the signup form as shown in the userena FAQ (http://docs.django-userena.org/en/latest/faq.html#how-do-i-add-extra-fields-to-forms) to add the avatar there but I don't know: A) if it's a good option and B) how to render the mugshot (ThumbnailerImageField) in a form (tried forms.ImageField without success).

Any help is welcome!
Bastian

Bastian

unread,
Sep 13, 2012, 5:41:59 AM9/13/12
to django...@googlegroups.com
Well it's easy, just follow the FAQ to add some extra fields and in the forms.py :

from django import forms    
from userena.forms import SignupForm

class SignupFormExtra(SignupForm):
    avatar
= forms.ImageField()

   
def save(self):
        new_user
= super(SignupFormExtra, self).save()

        profile
= new_user.get_profile()
        profile
.mugshot = self.cleaned_data['avatar']
        profile
.save()

       
return new_user

Cheers.
Reply all
Reply to author
Forward
0 new messages