Actually, just yesterday I extended the django-registration form to deal with my profile @ registration time For reference I used:
http://dmitko.ru/?p=546 and the link you previously posted, http://dewful.com/?p=70 It didn't require much code. The hardest part was sifting through some of the older irrelevant documentation in order to find instructions that worked. -Colleen ________________________________________ From: django-users@googlegroups.com [django-us...@googlegroups.com] On Behalf Of strayhand [tobyb...@gmail.com] Sent: Thursday, July 29, 2010 11:13 AM To: Django users Subject: Re: User Registration: Looking for tips Euan, Thank you for the response. I agree with what you're saying and it seems that I have two options before me. 1. Define simple form class for my registration process. Write a save method that posts to both the "User" model and the "UserProfile" model. I could start this process from scratch but I came across this post that I'm interested in. Have you by chance looked at any of the work James Bennett (http://www.b-list.org/) has done with registration? He has essentially taken the UserCreationForm as a guide and reworked it to save the form to two models. In this example he's storing activation key in the UserProfile model. http://www.b-list.org/weblog/2006/sep/02/django-tips-user-registration/ I think that I could use what he's demonstrating here and add my own fields. What are your thoughts on this code? There are a few comments below his post that I'll need to keep in mind. My main concern is how old the post is. I don't want to waste a lot of time with this approach only to find out that Django has gone in a different direction. 2. The second option would be to try the django-registration module and make some tweaks. Do you (or anyone else out there) have any experience with this module? http://bitbucket.org/ubernostrum/django-registration/overview Seems like this would get me up and running with a registration system a little more advanced than I currently have but it would still need to be tweaked to include all of my profile fields. Here's a blog post about tweaking the django-registration form by extending the class: http://dewful.com/?p=70 Please let me know if you guys have opinions one way or another about these two approaches. Thank you. On Jul 28, 11:47 pm, "euan.godd...@googlemail.com" <euan.godd...@gmail.com> wrote: > For the UserProfle model you've provided you won't be able to user > the UserCreationForm as there are a load of extra fields. Moreover > because User is a foreign key from that model it isn't a straight- > forward matter of using a model form. To get a single model form to > split the work to two underlying models would be a fair bit of work. > > Although ModelForm is great, if you want to do things which are a bit > off what they were intended to do I'd use a simple Form and create a > custom save method that writes out the data to the two models. That's > how we do our registration process since we create at least 6 model > instances at join time. > > Euan > > On 29 July, 06:45, strayhand <tobyb...@gmail.com> wrote: > > > I'm using the auth module for my project and I've got a registration > > form that's based on the "UserCreationForm" provided by > > "django.contrib.auth.forms" but it's only showing the username and > > password fields. > > > I want a registration process that requires users to fill out ALL of > > the "User" fields plus the fields in my "UserProfile" model. > > > If someone has some basic suggestions for how to modify the > > UserCreationForm to include these additional fields I'm all ears. I > > managed to find some basic examples of how to hide certain ModelForm > > fields or change their labels but nothing about adding additional > > fields, particularly from other models. > > > In addition to modifying the UserCreationForm I've come across a > > couple of leads: > > > 1. Build my own registration process following this example: > > >http://www.b-list.org/weblog/2006/sep/02/django-tips-user-registration/ > > > I'm concerned with how old this post is. Is this approach still valid > > given that it was posted in 2006? The author is using both the User > > model and his own UserProfile model. I think that I could adapt this > > for my purpose. > > > 2. Use the django-registration package provided by the same author > > >http://bitbucket.org/ubernostrum/django-registration/overview > > > I'm concerned with having to install additional packages into Django. > > It seems like this will make deploying my application on a Web host > > more difficult. Can anyone speak to this? > > > Thank you for your suggestions. I've provided my code thus far below. > > > # forms.py > > > from django import forms > > from django.contrib.auth.forms import UserCreationForm > > from django.http import HttpResponseRedirect > > from django.shortcuts import render_to_response > > from django.template import RequestContext > > > def register(request): > > if request.method == 'POST': > > form = UserCreationForm(request.POST) > > if form.is_valid(): > > new_user = form.save() > > return HttpResponseRedirect("/somewhere/") > > else: > > form = UserCreationForm() > > return render_to_response("registration/register.html", > > {'form':form,}, context_instance=RequestContext(request)) > > > # profiles.models.py > > > from django.db import models > > from django.contrib.auth.models import User > > from ylbbq.areas.models import Area > > > class UserProfile(models.Model): > > user = models.ForeignKey(User, unique=True) > > phone = models.CharField(max_length=12) > > address = models.CharField(max_length=70) > > city = models.CharField(max_length=50) > > > STATES = ( > > ('AK', 'Alaska'), > > ... > > ) > > > state_province = models.CharField(max_length=2, choices=STATES, > > verbose_name='State or Province') > > > COUNTRIES = ( > > ('USA', 'United States'), > > ('Canada', 'Canada') > > ) > > > country = models.CharField(max_length=20, choices=COUNTRIES) > > zip_code = models.CharField(max_length=5) > > birth_date = models.DateField() > > areas = models.ManyToManyField(Area) > > > # templates/registration/register.html > > > {% extends "base.html" %} > > > {% block title %} Account Registration {% endblock %} > > > {% block content %} > > <h1>Create an account</h1> > > > <form action="" method="post">{% csrf_token %} > > {{ form.as_p }} > > <input type =submit value="Create Account" /> > > </form> > > > {% endblock %} -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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-us...@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.