-
-
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
Import data with foreign key #37
Comments
Are you able to check your log file see what cause it to fail? pyexcel-io v0.4.x line: and pyexcel-io v0.3.x line: https://github.com/pyexcel/pyexcel-io/blob/v0.3.x/pyexcel_io/database/django.py#L68 |
God thank you for answer, it was a problem with the excel file formatting. However it's a bit of a shame to have to go through pyexcel logs to find this kind of error. Anyway thanks again for your work and your answer. |
Hmm... what if the save_to_database throw a exception in the first place? would it help you find the problem early? |
Yes to me it would definitely be a great feature. |
Hi again. I still have trouble with these imports and this time nothing is logged by django.py
Thanks in advance for any help. |
This means that equipment need to be saved in the database before the database give an id back. |
Yes I know, but equipment should be saved by save_to_database (item is of type Equipment). |
Alright, in this case where nothing is left, it is assumed that the item is created. However, the item was not there in the database. I would suggest that to set a break point in the django.py, right after the close() method. And then try upload items again. step through the code and see. |
pyexcel-io v0.4.1 with explicit exception is released. |
I was in a rush so I have written a workaround but I will debug this, try v0.4.1 and update |
New issue with pyexcel-io, here is my debugger content if it can be of any use to you. I tried commenting this line, but then it'll throw an attribute error: "module 'pyexcel' has no attribute 'save_as' ". In fact, a coworker already faced this error with v0.4.0 of pyexcel though we installed it and django-excel exactly in the same way. |
You are reproducing this problem here. Are you able to try logging it? At the meantime, I checked the package files pyexcel 0.5.0 and pyexcel-io 0.4.x and the packages are not having the same issue as this one: pyexcel/pyexcel-io#37, where an extra folder 'pyexcel' accidentally appeared in pyexcel-io. |
The screenshot you had is telling the uploaded file is empty hence an IOError will be thrown. |
I tried to use trace-pyexcel.py but it's not recognised. I've included logging lines in django_excel init since it's throwing the exception but I dunno where I can find this log file. By the way, my file is obviously not empty, actually data are read and I can see it in the debugger, but it throws an error anyway. |
the read() returned empty content, it could mean either no content uploaded or the file pointer was pointing at the end of the stream. So the latter case may apply to your exception. |
as to django_excel log, I guess it will go to your django log and you should be able to find out the log setting in settings.py. |
What kind of problem did you have here?
|
error: "module 'pyexcel' has no attribute 'save_as' " was transferred to #90. |
please try pyexcel-io v0.4.2. I think it should fix the problem: no attribute 'save_as' |
Sorry I was a bit in a rush for the project and debugging gave me no clue. I'll try and test this today if I have time and let you know. |
What if you insert an extra line into django-excel? In past, the django-excel developer has passed a file which has been read and get unexpected errors. That's why an IOError was raised up-front. The reason why a file could have been read is down to the other middleware in django. But this depends on the middleware.
|
How would you comment the error and get 'save_as' error? |
I tried adding this extra line, now I got AttributeError: "module 'pyexcel' has no attribute 'save_as'" l°50
Well I just commented the else in if content: |
Hmm, this means that you still have pyexcel/pyexcel#89. Could you quickly try this?
And I would recommend that you uninstall all previous versions of pyexcel-io, v0.4.0, v0.4.1 and pyexcel v0.5.0. And then re-install latest pyexcel and pyexcel-io. There is a un-wanted record in pyexcel-io 0.4.0 and v0.4.1 which removes pyexcel/init.py when you do uninstall. |
Indeed I tried in python console and pyexcel had no attribute save_as. I reinstalled pyexcel and with that extra line of your it seems to work ! |
And that also means some of your middleware has read the content. But I think I could put the extra line as a fix for un-wanted read by other django middleware. |
Hello and first of all, thanks for this package !
I'm having issue when trying to import data with a foreign key field. The code doesnt raise any error, but nothing is saved in database. I've tried using custom initialize as in the documentation, however though I obtain correct values, no object is saved in database. When trying the same code with entities without foreign keys, everything goes fine.
Please find attached my function code. Thanks in advance for any help.
ps : here is what print(row) prints : (types and values are as expected)
['SCHNEIDER ELECTRIC', 'A9L16577', 'v8', 'Z130', 'B', 'aaa', 1, 'dummy', <Groupe: Serveurs>]
`
def import_xls(item, form):
The text was updated successfully, but these errors were encountered: