I am already using UserCreationForm in my view to register users --
all OK.
Now I want to add  custom user fields  in my Profile model to my
registration form.
I already created a Profile model linked and linked it to User model.

What do I need to do to get the Profile fields in my template?

Below for relevant code (all working -- except I can't get my Profile
model.

What do I need to change in my view and/or template?

Many Thanks
Liam





### model ###

from django.contrib.auth.models import User

class Profile(models.Model):
    user = models.ForeignKey(User, unique=True)
    location  = models.CharField(max_length=60)


### view ###

def signup(request):
    form = UserCreationForm()
    if request.method == 'POST':
        data = request.POST.copy()    # comment is available here
        #debug.on
        errors = form.get_validation_errors(data)
        if not errors:
            # save the new user
            new_user = form.save(data)
            username = request.POST['username']
            password = request.POST['password1']
            new_user = auth.authenticate(username=username,
password=password)
            auth.login(request, new_user)
            return HttpResponseRedirect("/update_success/")
    else:
        data, errors = {}, {}
    form = oldforms.FormWrapper(form, data, errors)
    return render_to_response("registration/register.html",{'form' :
form})


### register.html ###

{% extends "base.html" %}

{% block title %}{% endblock %}


{% block content %}



  <h1>Create an account</h1>
  <form action="." method="post">
    {% if form.error_dict %}
      <p class="error">Please correct the errors below.</p>
    {% endif %}

    {% if form.username.errors %}
      {{ form.username.html_error_list }}
    {% endif %}
    <p><label for="id_username">Username:</label> {{ form.username }}</
p>

    {% if form.password1.errors %}
      {{ form.password1.html_error_list }}
    {% endif %}
    <p><label for="id_password1">Password: {{ form.password1 }}</p>

    {% if form.password2.errors %}
      {{ form.password2.html_error_list }}
    {% endif %}
    <p><label for="id_password2">Password (again):
{{ form.password2 }}</p>

    <p><label for="id_comment">comment: {{ form2.comment }}</p>

    <input type="submit" value="Create the account" />
  </label>

{% 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to