From ee6845c5b00092eb13ff10c538acd47faf209e1c Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Sun, 30 Apr 2017 01:27:26 +0200 Subject: [PATCH] Finally a nice singup form --- templates/form.html | 20 ---- users/forms.py | 10 +- users/models.py | 4 +- users/templates/users/signup.html | 177 ++++++++++++++++++++++++++++-- 4 files changed, 174 insertions(+), 37 deletions(-) delete mode 100644 templates/form.html diff --git a/templates/form.html b/templates/form.html deleted file mode 100644 index 69d5fd8..0000000 --- a/templates/form.html +++ /dev/null @@ -1,20 +0,0 @@ -
- {% csrf_token %} - - {% for field in form %} -
- -

- {{ field }} -

-

- {{ field.errors.as_text}} -

-
- {% endfor %} -
-

- -

- - diff --git a/users/forms.py b/users/forms.py index 0fbfe7e..aa46321 100644 --- a/users/forms.py +++ b/users/forms.py @@ -4,18 +4,12 @@ from django.forms import ModelForm from users.models import User class UserCreateForm(ModelForm): - password1 = forms.CharField(label='Password', widget=forms.PasswordInput(attrs={'class': 'input'})) - password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput(attrs={'class': 'input'})) + password1 = forms.CharField(label='Passwort') + password2 = forms.CharField(label='Passwort bestätigen') class Meta: model = User fields = ['username', 'email', 'twitter', 'github'] - widgets = { - 'username' : forms.TextInput(attrs={'class': 'input'}), - 'email' : forms.TextInput(attrs={'class': 'input'}), - 'twitter' : forms.TextInput(attrs={'class': 'input'}), - 'github' : forms.TextInput(attrs={'class': 'input'}), - } def clean_password2(self): diff --git a/users/models.py b/users/models.py index dbe8af4..0814550 100644 --- a/users/models.py +++ b/users/models.py @@ -2,5 +2,5 @@ from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): - github = models.CharField('github handle', max_length=128, blank=True) - twitter = models.CharField('twitter handle', max_length=128, blank=True) + github = models.CharField('github', max_length=128, blank=True) + twitter = models.CharField('twitter', max_length=128, blank=True) diff --git a/users/templates/users/signup.html b/users/templates/users/signup.html index a85a6dc..a37a6c2 100644 --- a/users/templates/users/signup.html +++ b/users/templates/users/signup.html @@ -1,20 +1,183 @@ {% extends "base.html" %} - {% block title %} Sign up{% endblock %} - {% block content %}

Registrieren

- {% if user.is_authenticated %} - You are alerady logged in, why in the world would you want to sign up ? - {% else %} - {% include 'form.html' with button_text='sign up' %} - {% endif %} + {% if user.is_authenticated %} + Was zur Hölle machst du bitte hier?
+ Du bist eingeloggt und willst du dich registrieren.
+ Geh heim du bist besoffen! + {% else %} +
+ {% csrf_token %} +
+
+ +
+
+
+
+ + + + + + {% if form.username.errors %} + + {% endif %} + +
+

+ {{form.username.errors.as_text}} +

+
+
+
+ +
+
+ +
+
+
+
+ + + + + + {% if form.email.errors %} + + {% endif %} + +
+

+ {{form.email.errors.as_text}} +

+
+
+
+ +
+
+ +
+
+
+
+ + + + + + {% if form.password1.errors %} + + {% endif %} + +
+

+ {{form.password1.errors.as_text}} +

+
+
+
+ +
+
+ +
+
+
+
+ + + + + + {% if form.password2.errors %} + + {% endif %} + +
+

+ {{form.password2.errors.as_text}} +

+
+
+
+ +
+
+ +
+
+
+
+ + + + + + {% if form.twitter.errors %} + + {% endif %} + +
+

+ {{form.twitter.errors.as_text}} +

+
+
+
+ +
+
+ +
+
+
+
+ + + + + + {% if form.github.errors %} + + {% endif %} + +
+

+ {{form.github.errors.as_text}} +

+
+
+
+ +
+

+ +

+
+
+ {% endif %}