added email field to signup

This commit is contained in:
MassiveAtoms 2020-07-09 10:41:41 -03:00
parent cce3b1e733
commit caa3022cdf
3 changed files with 20 additions and 2 deletions

Binary file not shown.

View File

@ -1,7 +1,25 @@
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
class SearchForm(forms.Form):
title = forms.CharField(label="Title", max_length=200)
author = forms.CharField(label='Author', max_length=100)
# identifier = forms.CharField(label='Identifier(ISBN, Google-id, amazon id)', max_length=20)
class UserCreationForm(UserCreationForm):
email = forms.EmailField(required=True)
class Meta:
model = User
fields = ("username", "email", "password1", "password2")
def save(self, commit=True):
user = super(UserCreationForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
if commit:
user.save()
return user

View File

@ -2,10 +2,10 @@ from django.shortcuts import render
from django.views import generic
from .models import Author, Book, Comment, Rating, BookAuthorLink, Publisher, Tag, BookTagLink, BookRatingLink, Data
from django.http import HttpResponseRedirect
from .forms import SearchForm
from .forms import SearchForm, UserCreationForm
from django.db import models
from django.db.models import Q
from django.contrib.auth.forms import UserCreationForm
# from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.contrib.auth import login
from django.contrib.auth.decorators import login_required