chrisdev/django-pandas

Column Translations in read_frame

FalseProtagonist opened this issue · 0 comments

A common use case (I'm guessing, since that's what I'm doing) is to:
Define models => do operations in dfs => save back down as models

This is kind of fiddly because of the column translations when dealing with fk columns.
read_frame(verbose = False) returns an _id suffix for the pk, and not for the fks
but Model(**kwargs) requires an _id suffix for the pk and also for the fks

So there's this translation that's happening that I either circumvent or do some fiddling to undo, the origin is the line:

fieldnames = [f.name for f in fields]

I'm wondering whether a default of:

fieldnames = [f.attname for f in fields]

might make more sense, although it's easy enough to wrap this and pass those fieldnames in. I'm curious whether there's a deeper reason for the current default.