M
M
maxclax2015-03-30 23:21:01
Django
maxclax, 2015-03-30 23:21:01

How to check object on save via console?

I have a field in the model:

class User(AbstractBaseUser):
    email = models.EmailField(_('user.model.email'), max_length=100, unique=True, validators=['validate_email'])

when saving the model through the shell, the field validation does not pass, specifically validate_email.
Tell me how to implement it? Maybe it’s worth doing through the def clean (self) method: but how to register a validator specifically for checking the validity of email

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Shikanov, 2015-03-30
@dizballanze

And when saving, validation does not occur. Here's from the documentation:

Note that full_clean() will not be called automatically when you call your model's save() method. You'll need to call it manually when you want to run one-step model validation for your own manually created models.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question