Updating User model in Django with class based UpdateView

前端 未结 2 712
情歌与酒
情歌与酒 2020-12-13 05:09

I am trying to update the Django User model with the class based UpdateView that automatically renders with the current user but am getting an error that a pk or slug is req

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 05:10

    I need to override the get_object() method on the update view and do not need to override form_valid. The custom get_object() method is:

        def get_object(self, queryset=None):
            return self.request.user
    

提交回复
热议问题