def view_group(request, group): setting_objects = register.in_group(group) setting_names = (s.name for s in setting_objects) settings = getsettings(request.user, setting_names) form_type = get_settings_form(setting_objects) if request.method == 'POST': form = form_type(request.user, request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(request.path) else: form = form_type(request.user) return render( request, 'usersettings/view_group.html', dict( group=group, form=form, ), current_app='usersettings', )
def __init__(self, user, *args, **kwargs): self.user = user kwargs['initial'] = getsettings(user, [s.name for s in self.settings]) super(SettingsForm, self).__init__(*args, **kwargs)