What validation do you need? Much can be done in the database with
constraints, especially check constraints.

On Wed, 30 Jun 2021 at 08:05, Михаил Итпрогер <crazytheo...@gmail.com>
wrote:

> Hello, I am currently developing a reusable application using the Django
> framework.
>
> It just so happens that the instances of the models of this application
> will most often be created inside the code, and not in the forms.
> I've created validators for fields that only work in forms, but I would
> like to reuse them for creating/updating objects as well.
> The Django documentation says that validation only occurs on forms, but it
> is not written for what reason.
>
> I have tried many solutions to deal with this problem, but they all have a
> significant drawback - when creating an instance from a form, the
> validation happens twice.
>
> For example, with __setattr__():  once when the concstruct_instance() is
> called, the second time when full_clean().
>
> With save(): first full_clean(), and then my validation in save().
> I'm really interested in why the opportunity to validate everything at the
> object level was missed, because when creating objects outside the forms,
> you can enter any values ​​into the fields that contradict the
> restrictions.
>
> I could solve this problem, which would require small changes in the
> validation logic, but first I need to consult with you.
>
> Besides, maybe you can tell me an alternative solution.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/E619D0E2-3B55-478F-895B-0F59848BAFA6%40hxcore.ol
> <https://groups.google.com/d/msgid/django-developers/E619D0E2-3B55-478F-895B-0F59848BAFA6%40hxcore.ol?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM30TzCLFMsktSLEnZjUhr6f4FsF7eg%3DpzcFqmSLyO0sfA%40mail.gmail.com.
  • Lac... Михаил Итпрогер
    • ... 'Adam Johnson' via Django developers (Contributions to Django itself)
      • ... 'Adam Johnson' via Django developers (Contributions to Django itself)
        • ... Args Kwargs

Reply via email to