Conversation
b70d926 to
089e414
Compare
|
@aminalaee Сan you review, plz? |
| for column, value in row.items(): | ||
| if column not in columns: | ||
| continue | ||
| if value and "," in value: |
There was a problem hiding this comment.
@alserious dont you think it would be easier and more robust for importing relations by ID (or PK) only instead of relying on str? Addresses can be just string field containing string Address 1, Address 2.
Also, I think we should disable O2M and M2M import: as it could easily be done by adding/importing two entries in Address table (which is correct way of doing it).
There was a problem hiding this comment.
@mmzeynalli Thanks for the review. I agree that importing data without specifying relationships is a more correct and simpler method, but in practice, we need to import a lot of data like:
|username|address|role|...|
|sam|relation to address(new york)|relation to role(author)| ...|
And then manually filling in the relationships is problematic. Maybe make this optional? With or without importing relationships?
| for row in data: | ||
| n_row = [] | ||
| for value in row.getlist(relation_name): | ||
| if value == str(relation_obj): |
There was a problem hiding this comment.
this is really ineffective. If we at least had list of PKs, we could have used: .where(id.in_(list))
There was a problem hiding this comment.
Yes, it seems like this is the only way, as long as we don't use a primary key list. If we remove the relationship import, it won't be a problem.
There was a problem hiding this comment.
Lets not do this, it can be problematic for for duplicate data if there are two rows data with 'Address 1'. Let user to do the following:
- Import first data, no relations
- Filter out in admin newly imported
- Export that data and get IDs
- Update 2nd csv
- Upload 2nd csv
column_import_list,column_import_exclude_list,can_importby default disabled.__str__method of the SQLAlchemy model. Relation models in a CSV file are separated by a comma.