action_list = user_stream(self.request.user)
user_stream = Action.objects.user
class Action(models.Model):
...
objects = actstream_settings.get_action_manager()
class ActionManager(GFKManager):
@stream
def user(self, object, **kwargs):
q = Q()
qs = self.filter(public=True)
actors_by_content_type = defaultdict(lambda: [])
Еще строк 20...
e = self.request.user
e.Member_list.all()
# output: [<Group: Group object>]
self.request.user.Member_list.all()
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)
if form.is_valid():
args= form.save(commit=False) # принимаем данные от формы
args['поле_которое_заполняется_само'] = запрос_из_базы_данных
...
args.save()