Keibry
Keibry

Reputation: 31

Passing data from DetailView to CreateView django

I have a UserDetailView

which has a url of /user/1000/ and displays object.id equals to 1000

Within my UserDetailView I have an ADD button which redirects to UserNumberCreateView

In the next view which is the UserNumberCreateView I want to pass the 1000 value to UserNumberCreateView as primary key, how can I pass the 1000 value to my UserNumberCreateView without submitting the UserNumberCreateView?

Upvotes: 1

Views: 216

Answers (1)

josemfc
josemfc

Reputation: 108

There are already questions about redirecting with parameters.

If you mean that the button links to the UserNumberCreateView, you may just make its URL like /user/1000/numbercreate/ and in the template href="{% url 'app:numbercreate' object.id %}".

Upvotes: 1

Related Questions