diff --git a/requirements.txt b/requirements.txt index 394957f..ed4b331 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ Django==2.2.1 pytz==2019.1 setuptools==41.0.1 -sqlparse==0.3.0 \ No newline at end of file +sqlparse==0.3.0 +py3dns==3.2.0 +validate-email==1.3 \ No newline at end of file diff --git a/users/forms.py b/users/forms.py new file mode 100644 index 0000000..a9c7443 --- /dev/null +++ b/users/forms.py @@ -0,0 +1,18 @@ +from django.contrib.auth.forms import UserCreationForm +from django import forms +from django.contrib.auth.models import User +from .models import ProfileModel + + +class UserRegisterForm(UserCreationForm): + email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.') + + class Meta: + model = User + fields = ['username', 'email', 'password1', 'password2'] + + def save(self, commit=True): + user = super(UserRegisterForm, self).save(commit=False) + if commit: + user.save() + return user diff --git a/users/models.py b/users/models.py index 423cc36..9b628c4 100644 --- a/users/models.py +++ b/users/models.py @@ -1,5 +1,7 @@ + from django.db import models from django.contrib.auth.models import User +from django.urls import reverse # Create your models here. @@ -9,3 +11,9 @@ class ProfileModel(models.Model): discription = models.CharField(max_length=500) dob = models.DateField() profile_image = models.ImageField() + + def get_absolute_url(self): + return reverse('login') + + def __str__(self): + return self.university diff --git a/users/templates/base.html b/users/templates/base.html index 3d4305f..0f76c77 100644 --- a/users/templates/base.html +++ b/users/templates/base.html @@ -8,6 +8,7 @@ +
@@ -20,5 +21,9 @@