New to Django.
When I submit a signup form with this, the password is human readable in the 
database. It seems like it should be hashed?
Looking at some Google pages, it seems I need to subclass UserCreationForm. 

I tried that instead of forms.ModelForm and now it complains my form doesn't 
have "password1" and "password2"; which is not what I want. I just want a 
single password field.

Can someone give me pointers on how I should go about this?

Thanks!


Models:
class User(models.Model):
    name = models.CharField(max_length=32)
    username = models.CharField(max_length=16, primary_key=True)
    mail = models.EmailField(max_length=254)
    password = models.CharField(max_length=64)
    status = models.CharField(max_length=32)
    create_tstamp = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        user = "%s: %s, %s" % (self.username, self.mail, self.name)
        return user

class SignupForm(forms.ModelForm):
    class Meta:
        model = User
        fields = ["username", "mail", "password"]


View:
def signup(request):
    if request.POST:
        form = SignupForm(request.POST)
        if form.is_valid():
            newUser = form.save()
            return HttpResponseRedirect(reverse('dashboard'))
    else:
        form = SignupForm()        
    return render(request, "registration/signup.html", {'form': form,})


I am using Bootstrap and here is my signup.html for reference:

    <form class="form-signin" method="post" action="">
        {% csrf_token %}
        <h4 class="form-signin-heading">Signup for Globexch account</h4>
        <p>It's free. You can also <a href="/login">Login</a>.</p>

        {% if form.username.errors %}
            <p class="alert alert-warn">{{ form.username.errors|join:", " }}</p>
        {% endif %}
        <input id="id_username" type="text" name="username" {% if 
form.username.value %}value="{{ form.username.value }}" {% endif %} 
class="input-block-level" placeholder="Login name">


        {% if form.mail.errors %}
            <p class="alert alert-warn">{{ form.mail.errors|join:", " }}</p>
        {% endif %}
        <input id="id_mail" type="text" name="mail" {% if form.mail.value 
%}value="{{ form.mail.value }}" {% endif %} class="input-block-level" 
placeholder="u...@example.com">


        {% if form.password.errors %}
            <p class="alert alert-warn">{{ form.password.errors|join:", " }}</p>
        {% endif %}
        <input id="id_password" type="password" name="password" 
class="input-block-level" placeholder="Password">

        <button class="btn btn-large btn-primary" type="submit">Let me 
in</button>
    </form>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to