Django4, Post file (pdf) and get file (pdf)

Hello Everyone.

I’ve one application Django + react. And I don’t know what I can do to review documents.
For example, I want to submit the file “blabla.pdf” to the application, specifying “/doc/review/blabla.pdf” as the desired URL and after that, I want to submit other versions to update and the original version of the file can be accessed at the URL (“/doc/review/blabla.pdf?revision=0”).

Does anyone have one idea? I can submit and register the file normally but I can’t see this file in one Django route.

Thank you so much!

i think your problem and my problem is the same, i have successfully uploaded a pdf file but don’t know how to display that uploaded pdf file on html web page associated with Django Template.

It’s best to start a new post rather than reply to an old unanswered question.

But I think the answer is that you can’t display a PDF in an HTML page easily. You can link to the file and then it will probably display in the browser window.

1 Like

Welcome @Eminence09 !

See JavaScript Is Everywhere: How to display PDF in html web page for some ideas. (I have not verified these, but they look right to me.)

1 Like

sorry to say but it seems like you don’t understand my problem. here is the full explanation of a problem: I’m currently working on a Django project that which simply takes a pdf file through Django Views.py and parse the file object or path to the html template. At this point I don’t know what to write in views.py and in the html template so that it shows up PDF file on the web page.

If you understand then reply…

You don’t parse the file object. You use the url attribute of the file field to have Django generate the appropriate url for the file reference. That url is what is used in the src attribute.