2

I want to modified django third party model. Here the original code.

default_price = models.DecimalField(
        decimal_places=2, max_digits=7,
        null=True, blank=True,
        verbose_name=_("Default price"),
    )

I want to change max_digits=7 to max_digits=9, so it becomes:

default_price = models.DecimalField(
        decimal_places=2, max_digits=9,
        null=True, blank=True,
        verbose_name=_("Default price"),
    )

Is it possible to modified django third party model without directly touch original third party code or fork?

Thanks

Ivo
  • 3,890
  • 5
  • 22
  • 53
dayongky
  • 21
  • 4

1 Answers1

0

I solve it with this two lines code in my models:

from thirdparty.models import ParentModelClass
ParentModelClass._meta.get_field('default_price').max_digits = 9

then makemigrations && migrate

voila it work, but i don't know any downside using this tricks.

It thanks to Peterino comments on this https://stackoverflow.com/a/2357942/2579404

Hope it will help others with similar situation as well.

dayongky
  • 21
  • 4