Skip to content
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

Model-method transformation doesn't work after mapping #120

Open
gabbork opened this issue May 19, 2020 · 0 comments
Open

Model-method transformation doesn't work after mapping #120

gabbork opened this issue May 19, 2020 · 0 comments
Labels

Comments

@gabbork
Copy link

gabbork commented May 19, 2020

Maybe putting a little abstract of the code will explain better what is happening:
file.csv

ColumnName
"144,54"
"435,12"

models.py

MyModel(models.Model):
    my_attr_name = models.DecimalField(max_digits=10, decimal_places=2)
    objects = CopyManager()

    def copy_ColumnName_template(self):
        return """
            replace(%(name)s::text, ',', '.')::numeric * 1000
        """

management command

insert_count = MyModel.objects.from_csv(
    csv_path,
    mapping={"my_attr_name": "ColumnName"}
)

When I execute the command, I get a django.db.utils.DataError: invalid input syntax for type numeric: "144,54".
It happens the same on any field typology, it's like the copy_ColumnName_template is skipped.

Am I missing something or using the transformation in a bad way? Without mapping, everything works as expected. Thanks

@palewire palewire added the bug label Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants