Django
3
Вклад в тег
class UserUpdateView(LoggedInMixin, UpdateView):
model = User
context_object_name = 'user_object'
template_name = 'basics/profile_update.html'
form_class = UserUpdateForm
class UserUpdateForm(ModelForm):
class Meta:
model = User
fields = ('avatar', 'birthday', 'sex', 'first_name', 'last_name', 'email')
widgets = {
'birthday': SelectDateWidget(years=range(1940, 2014))
}
def get_or_none(model, **kwargs):
try:
return model.objects.get(**kwargs)
except model.DoesNotExist:
return None
member = Member.objects.get(user=self.request.user, uni=self.object)
member=get_or_none(Member, user=self.request.user, uni=self.object)
e = self.request.user
e.Member_list.all()
# output: [<Group: Group object>]
self.request.user.Member_list.all()