How to get a django field value throw a custom models.Field?

271 Views Asked by At

I have a custom field:

class MyCustomTextField(models.Field):
(...)

and use that on my model:

class MyModel():
  encrypted_password = MyCustomTextField(null=True)
  password_seed = models.TextField(null=True)

I need when I use MyModel to grab encrypted_password, I need to grab first password_seed and return a new value using the password_seed value.

How can I do that, since custom model is instantiate before the data comes to the model?

1

There are 1 best solutions below

0
On

read this article from Django docs. you should override the method

def deconstruct(self): ...

of MyCustomTextField