简体   繁体   中英

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?

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 %}".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM