I am trying to access excel files through the django-admin model viewing portal.
Each excel file is generated through a seperate algorithm, and is already in a directory called excel_stored
each excel file is generated with an ID that corresponds to its model # in django. So it would be excel_%ID%.xlsx or excel_23.xlsx for example.
I want my django FileField() to access the relevant excel file so that I can download it from my django admin portal, just like I can access my other model information (city name, time uploaded, etc).
Here is a pseudo-code of what I'd want to do:
My models.py would look like this
excel = models.FileField()
The process of saving would look like this
create_excel()
### EXCEL WAS SAVED TO DIR: excel_stored ###
save_excel = Model(excel = file.directory((os.path.join(BASE_DIR, 'lead/excel_stored/excel_%s.xlsx' %ID))
save_excel.save()
Id then be able to download it like this https://i.stack.imgur.com/4HRUU.gif
I know there's a lot I'm missing, but most documentation I find refers to uploading an excel file through forms, not accessing it.
I've been stuck on this for a while, so I'd appreciate some direction! Thank you!
Related
I'm working on my first project in Django and I'd really like to have some advice from people with more experience then me since right now I'm a little stuck on what road take to keep developing my project.
This is my plan to develop my project:
Create a modelsFileFields so that my user can upload one or more standarded excel file
Read it and create variables with pandas
Create an html page with the graph with chart.js and render it in pdf with ReportLab
Store the pdf in my user profile usinig primary key so that they can see it and download it again.
My main problem right now is to store or not the information that are in the excel file in my database. Since getting the information in the excel file is what is important to me, my first thought was to import them and the only thing that it keeping me from doing so is the quantity of column that I have. This how my excel file looks like:
total partial [...]
user1 10 4
user2 18 6
I have more then 60 variable in my excel file (so I'd need a model with more then 60 fields) and they should be doubled since I'd need the information from user1 and also user2.
So I'd like to ask if I should give up on import the csv to my database since how much big it would be and also if what I'm plannning to do has sense or if there is a better way to do so (every exemple project is welcomed).
Thanks for the helps!
I have written a Django app that does a database query and displays the data in a table. I want to create a link at the bottom of the page that allows the user to export this data to a csv file. So basically I want to take the query object from the original view and pass that to the csv export view. How do I do this?
(Assuming you need to download the same table's data into csv file) You can do this without another server call with javascript:
As reference you can see: Here
Ok,
I had a look at the UploadFile Class documentation of the Django framework. Didn't find exactly what I am looking for?
I am creating a membership management system with Django. I need the staff to have the ability to upload excel files containing list of members (and their details) which I will then manipulate to map to the Model fields.
It's easy to do this with pandas framework for example, but I want to do it with Django if I can.
Any suggestions.
Thanks in advance
you can use xlrd to read excel files
in client side you just submit a form with file input.
on server uploaded file stored on request.FILES
read file and pass it to xlrd then process sheets and cells of each sheet
I am newbie to Django, and following this SO question, I was able to create an application that helped me to upload an image to the server from the user end:
Need a minimal Django file upload example
However, I wish to access the database wherein the information about the updated files has been stored. Within the env and that directory, when I run sqlite>.database, I get the following output :
sqlite> .databases
seq name file
--- --------------- ----------------------------------------------------------
0 main
1 temp
I am not able to locate where my database has been stored, and how to access it. How do I get to access the database, and view it? ( so as to alter it)?
I want to create OpenERP 6.1 module with a upload binary file field as one of the fields in view.
The file will be stored in database as binary data, but before storage in database I need to parse that file, and save data as part of the other created module.
So, I don't know how to specifiy filed for upload files in a view xml file, and also how to run the uploading process. Can somebody help me about this? Some code snippets or advice how to do that.
Take a look at the way the attachments module works, particularly the binary data column. You should also look at the screen definition.