-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question - additional field #17
Comments
Hi, Joseph What I understood your intention is to insert some custom data from your form during the file import, whereas the tutorial shows only database import without 'salt'. One idea is take advantage of row initializer to do custom change. The other idea is to use get_sheet( get_book )to obtain the pyexcel.Sheet( pyexcel.Book) instance, with which you can do data manipulations. Then you can use pyexcel.Sheet.save_to_django_model ( pyexcel.Book.save_to_django_models ) for the data import. Hope it helps. Chfw |
Hi Jaska, Thank you for your answer. Yes you are correct, for every row that is imported, I would like to set one specific field. For example: I was trying to look at the first option that you proposed : initializer. However, I am exactly sure how to use this method. Should I pass a query? or just a specific parameter? Thanks in advance. Joseph |
Under the first route, the initializer is expected to return a list of values for each new row/data entry, which is in the same order as the column_names. The default assumption is that the number of column names matches the number of data columns and their order is the same. Your use case is, the 4th column is outside the spreadsheet. Recommended route is to go with the second one: get a sheet out, populate 4th column and save to django model. Hacking route is via first route, set column_names = [number, name, address, account_id](note, account_id should be the exact database field name), then in your row initializer, add: row.append(the_same_account_id_for_all), which append a 4th item onto the row. This could work out too. |
Hi everyone,
I still consider myself a newbie on django but i've been trying to toy around with django-excel which is working awesomely so far.
I would like to go a bit further and add a field (charfield) in my form that I would like to insert at the same time as the excel import and that will be the same for all rows.
Any directions you guys could point me to?
Thanks!
Joseph
The text was updated successfully, but these errors were encountered: