Skip to content

Instantly share code, notes, and snippets.

@jcockhren
Created February 2, 2014 19:47
Show Gist options
  • Save jcockhren/8773742 to your computer and use it in GitHub Desktop.
Save jcockhren/8773742 to your computer and use it in GitHub Desktop.
Shouldn't this pull the most recent version of the user data on get? see https://gist.github.com/jcockhren/8762001 for supporting code.
class SettingsView(UpdateView):
model = CustomUser
form_class = UserForm
#form = UserForm(self.instance)
template_name = 'account/settings.html'
success_url = '/account/settings'
fields = ['first_name',
'last_name',
'email',
'company']
def get(self, request, *args, **kwargs):
form = UserForm(initial=model_to_dict(CustomUser.objects.get(id=request.user.id)))
return render(request, self.template_name, {'form': form})
def get_object(self, queryset=None):
return CustomUser.objects.get(id=self.request.user.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment