[Django]-How to feed success url with pk from saved model?

11👍

def get_success_url(self, **kwargs):
    # obj = form.instance or self.object
    return reverse("profile", kwargs={'pk': self.object.pk})

You expect a primary key on the request object, which makes no sense. The instance (self.object) is where you should retrieve the primary key from.

Leave a comment