Django Admin Interface Ignores Django Rest Serializer Validators

23 views
Skip to first unread message

C James Cook (Jim)

unread,
Jun 23, 2024, 11:32:00 PM (9 days ago) Jun 23
to Django REST framework
If a serializer implemented based on the Django Rest framework ModelSerializer class defines a validator, will it be called when an API endpoint is accessed through the standard Django admin interface?

I have implemented validate function(s) in my backend implemented using the Django Rest framework. The validate function is called without a problem if I use a curl command or other React-based frontend to access the backend endpoints. However, if I use a browser to access the backend via the /admin endpoint, the validate functions are not called.

Near as I can figure, the Admin interface will call single field validation functions in the model from db.models.fields.__init__.run_validators() 
which is called by db.models.fields.__init__.clean 
which is called by db.models.base.clean_fields
which is called by db.models.base.full_clean
which is called by forms.models._post_clean
which is called by forms.forms.full_clean
and so on.


Reply all
Reply to author
Forward
0 new messages