1

I am trying to populate data into the following model from a csv and using update_or_create() in a loop to do that.

class TargetPlace(models.Model):
    name = models.CharField(max_length=100)

The csv may have some entries which have leading or trailing white spaces and I want to get rid of those.

I saw that CharField's in Django >=1.9 have a strip argument that takes care of this by default (since its True by default). I am using Django 1.10 but still seeing duplicate entries in the model (those with and without leading white spaces).

Does the strip argument not work that way?

Anupam
  • 14,950
  • 19
  • 67
  • 94

1 Answers1

0

I guess I got confused with the CharField in a Form vs CharField in a Model. CharField in a Model does not seem to have any such argument

Anupam
  • 14,950
  • 19
  • 67
  • 94
  • I was just looking at the source code and you are right, it doesn't have any such argument. – AKS Apr 04 '17 at 07:01
  • Also, [this](http://stackoverflow.com/a/38320995/15267030) answer throws some more light – Anupam Apr 04 '17 at 07:07