Gasim
Gasim

Reputation: 7961

Django how to use model DecimalField with additional character values?

I have an input box that must accept the following parameters:

I know that I can create a custom "fail" BooleanField that gets set to True if "x" is typed. However, I would like to know if it is possible add these values inside the DecimalField. Maybe, use CharField with Decimal Validation. However, trying to use it with CharField and Decimal Validation failed. So, I am not sure how else I can achieve this.

Thanks!

Upvotes: 0

Views: 91

Answers (1)

HenryM
HenryM

Reputation: 5793

Could you do something with validators like:

extended_decimal_field = models.CharField(
    max_length=10,
    validators=[RegexValidator('^\d{8}[.]{1}\d{2}|['X']{1}$')]
)

I don't think this is exactly right but might be right track?

Upvotes: 1

Related Questions