Skip to content

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

Description

@gabbork

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions