How to redirect url with argument to another page in Django? (Updateview, Genericview)

Asked

Viewed 500 times

1

Well, I have a very pertinent question. I am with an editing class of Django, and when I edit the user, I need it to call from the detail class of the same (Detailview), the two classes are working, but when I call the url that sends to Detailview, it gives error, which is obvious, since Detail view needs user id via GET. However, how to pass this user id via get to the Updateview class, since it uses success_url? follows the code of the classes said:

Updateview:

class UpdateUserView(LoginRequiredMixin, IsMaintainer ,UpdateView):
    model = User
    context_object_name = 'u'
    template_name = 'update-user.html'
    fields = ['name', 'email', 'nivel']
    success_url = reverse_lazy('accounts:detail')

Detailview:

class DetailUserView(LoginRequiredMixin, IsMaintainer ,DetailView):
    model = User
    context_object_name = 'u'
    template_name = 'profile.html'

1 answer

1


Browser other questions tagged

You are not signed in. Login or sign up in order to post.