How to add multiple views in one template of django ?
Is it possible to add more than one view in template . I have view A that deals with file uploads , and view B that deals with file permissions . How do I put them in one template ? Both are in di开发者_运维知识库fferent apps .
I don't think this is really the best way to go about things. Views are not really meant to be used that way. They should map to requests on a one to one basis.
You might, in fact, need to write a third view which does all the things that the two other views do. Situations like this are where the class based views become very handy. I would try to break out the code that handles all the forms and processing in to separate functions, and just import those when needed.
Another Solution is to do this via ajax somehow. Load those portions of the page separately either after load, or on submit.
You should use custom middleware for that kind of things, so there's no need for different views.
精彩评论