On Tue, Jun 2, 2009 at 9:10 AM, Marco Bazzani <alfred.einst...@gmail.com>wrote:
> > On Mon, Jun 1, 2009 at 23:19, V <viktor.n...@gmail.com> wrote: > > > > On Jun 1, 6:50 pm, Marco Bazzani <alfred.einst...@gmail.com> wrote: > >> I'm trying to extends django-registration app with some more fields in > >> the moment of registration > >> those fields are saved in a subclass of User > >> > >> for reference here are the form classes: > http://bitbucket.org/ubernostrum/django-registration/src/tip/registra... > >> > >> ok here is my code > >> > >> #models.py > >> class Customer(User): > >> company = > models.CharField(_('Company'),max_length=200,blank=True) > >> address = models.CharField(_('Address'),max_length=255) > >> state_province = > models.CharField(_('State/Province'),max_length=200) > >> country = > >> models.CharField(_('Country'),max_length=3,choices=COUNTRY_CHOICES) > >> phone_number = models.CharField(_('Phone Number'), max_length=20) > >> fax_number = models.CharField(_('Fax Number'), > max_length=20,blank=True) > >> other_contacts = models.TextField(_('Other Contacts'),blank=True) > >> > >> objects = UserManager() > >> > >> #forms.py > >> from registration.forms import RegistrationForm > >> from django import forms > >> from customers.models import Customer > >> from classmaker import classmaker > >> > >> class ProfileForm(forms.ModelForm): > >> class Meta: > >> model = Customer > >> fields = ( > >> 'state_province', > >> 'country', > >> 'phone_number', > >> 'fax_number', > >> 'other_contacts', > >> ) > >> > >> class RegistrationFormProfile(RegistrationForm, ProfileForm): > >> __metaclass__ = classmaker() > >> > >> the classmaker was necessary to solve the metaclass conflict problem > >> as described herehttp://www.djangosnippets.org/snippets/703/ > >> > >> anyway everythings seams to be ok a part from the fact that only > >> ProfileForm is displayed in the template > >> even if I switch the order of the inheritance. > >> > >> I've also modified some django registration to use my Model instead of > >> User ( but shouldn't be the origin of the problem) > >> > >> any clue ? > >> > >> cheers > >> Marco > > > > I don't have any clues on your problem, except that I can't really > > understand why do you extend the User model as you do, instead of > > adding a profile model that has a OneToOneField to User > > > > this way you don't have to edit django-registration, and you can have > > a fairly simple save method in your profile where you first create the > > User, and then attach a profile to it. I would go this way. > > > > V > > > > > > > how do you collect additional user data during registration with your > method ? > > > > You can define your own form class (which can inherit from one of the existing form classes defined in the App) and define custom actions in it's save method. See [1] for an example of a form I am using. You can then pass the "register" view your own form using the "form_class" parameter as explained in [2]. -- Best, R [1] - http://dpaste.com/50347/ [2] - http://bitbucket.org/ubernostrum/django-registration/src/tip/docs/views.txt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---