calibre-web-companion/CalibreWebCompanion/library/forms.py
2020-07-09 10:41:41 -03:00

26 lines
775 B
Python

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