1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
from django import forms
from django.utils.translation import ugettext_lazy as _
from django_registration.forms import RegistrationForm
from .models import User, UserProfile
class UserForm(RegistrationForm):
class Meta(RegistrationForm.Meta):
model = User
class ProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ['bio', 'photo', 'website']
labels = {
"photo": _("Profile photo"),
"bio": _("Bio. A little about you. links are fine, line breaks are not. Keep it short and sweet, 350 characters max"),
"website": _("If you have a personal website, plug it in here."),
}
widgets = {
'bio': forms.Textarea(attrs={'cols': 104, 'rows': 10, 'class': 'textarea-rounded'}),
}
def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user", None)
super(ProfileForm, self).__init__(*args, **kwargs)
|