Django Version - 1.10.5 I have uploaded the file on MongoDB, with a few fields like e-mail, employee_id and of course the file from an HTML page. I can see it in mongoDB. What I want to do is retrieve the data on an another HTML page using one of those fields(for example putting in a email id that was used to upload the article will give the entire article on the same HTML page.) . How do I go around that?
-
1Where are you stuck? Do you know how to do this with standard Django forms and models? Do you know how to query MongoDB?Daniel Roseman– Daniel Roseman2017-04-11 11:56:32 +00:00Commented Apr 11, 2017 at 11:56
-
I did it with standard forms and models, used post method to put data in mongoDB I can see the data in Mongo. I know how to query MongoDB, I just want to display the data on a HTML page using one of the fields that I used while uploading the fileSuyash– Suyash2017-04-11 12:04:34 +00:00Commented Apr 11, 2017 at 12:04
-
And ? Where are you stuck exactly ??? The views and templates parts of Django are fairly extensively documented so I fail to see what your problem is... Unless you didn't bother reading the doc and doing the tutorials, in which case well, it might be time to do so.bruno desthuilliers– bruno desthuilliers2017-04-11 12:11:14 +00:00Commented Apr 11, 2017 at 12:11
-
I have to write the code in in the notepad that I made the HTML in. Eg : <body> "what code should go here to display the MONGODB data" </body> Yes I haven't been through the documents thoroughly, I didn't have time so by the time I am doing other things I thought I would ask for help here on stack-overflowSuyash– Suyash2017-04-11 12:41:36 +00:00Commented Apr 11, 2017 at 12:41
1 Answer
From my understanding of the question, current state is:
- You have imported data to MongoDB
- You want to retrieve some data into HTML
I didn't understand where you are stuck and hence simple steps would be to create your models.py file defining the fields that you mentioned, email_id, employee_id, etc. Check details on how
Django models API lets you create, retrieve, update and delete objects. Next topic in this documentation page.
I recommend reading through Django documentation thoroughly and trying out things in a demo app from here - Django Models and Databases
Extra: You could use raw SQL queries if you used SQL based DB. But Django quotes:
You should be very careful whenever you write raw SQL. Every time you use it, you should properly escape any parameters that the user can control by using params in order to protect against SQL injection attacks. Please read more about SQL injection protection.