Answer the question
In order to leave comments, you need to log in
How to write an agreement to send email notifications (django)?
Good afternoon.
Created a simple user account. Added to it: upload photo and gender selection (male/female). I can’t figure out how to add correctly - Agreement for sending notifications to the mail, who can tell?
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from .models import Profile
class UserRegisterForm(UserCreationForm):
SEX_CHOICES = (
('m',u"мужской"),
('w',u"женский"),
)
email = forms.EmailField(
label='Введите Email',
required=True,
widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Введите Email'})
)
username = forms.CharField(
label='Введите логин',
required=True,
help_text='Нельзя вводить символы: @, /, _',
widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Введите логин'})
)
password1 = forms.CharField(
label='Введите пароль',
required=True,
help_text='Минимальный пароль 8 символов',
widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'Введите пароль'})
)
password2 = forms.CharField(
label='Подтвердите пароль',
required=True,
widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'Повторно введите пароль'})
)
sex = forms.ChoiceField(label=u'Пол', choices = SEX_CHOICES)
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']
class UserUpdateForm(forms.ModelForm):
SEX_CHOICES = (
('m',u"мужской"),
('w',u"женский"),
)
email = forms.EmailField(
label='Введите Email',
required=True,
widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Введите Email'})
)
username = forms.CharField(
label='Введите логин',
required=True,
help_text='Нельзя вводить символы: @, /, _',
widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Введите логин'})
)
sex = forms.ChoiceField(label=u'Пол', choices = SEX_CHOICES)
class Meta:
model = User
fields = ['username', 'email', 'sex']
class ProfileImageForm(forms.ModelForm):
img = forms.ImageField(
label='Загрузить фото',
required=False,
widget=forms.FileInput
)
class Meta:
model = Profile
fields = ['img']
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question