[Django]-Django User model UpdateView "No URL to redirect to"

4👍

✅

Why did you put the get_absolute_url method on a proxy, rather than the User model itself? If you wanted to do this, you would have to use UserMethods as the model in your view.

But the fix for the other approach is to get the user_id from self.object:

return reverse('companies:user_detail', kwargs={'user_id': self.object.id})

2👍

Try this on your model.

class UserMethods(User):
    def get_absolute_url(self):
        return reverse('companies:user_detail', args=(self.id,))

Whenever you want to provide this url in the template just type {{ object.get_absolute_url }}.

Leave a comment