0

I have a model that is as follows:

class Car(models.Model):
   make =  models.CharField(max_length=128, verbose_name=_("car make"), blank=True)

I now need to refactor this so that make becomes a class of it's own.

class Car(models.Model):
   make =  ForeignKey(CarMake, verbose_name=_("car make"), null=True, on_delete=models.CASCADE, blank=True)

One way I thought of was changing make to legacy_make and adding a new field, _make, and then a property / getter, but it doesn't work (I understand you can't do queries this way?)

Is the best ways really to

a) Migrate old data to use new make class or

b) Change all references to take into account possible new car make if it is present

user3553653
  • 127
  • 1
  • 8

1 Answers1

0

I decided to change the charfield to a foreignkey and migrate the data according to this: https://stackoverflow.com/a/36000084/3553653

user3553653
  • 127
  • 1
  • 8