Answer the question
In order to leave comments, you need to log in
How to set one clean method on many forms at once?
I have one clean method that renames the uploaded photo.
To make it work in all places, you need to put this clean method in all admin forms (and there are quite a few of them throughout the project).
Is it possible to specify one method somehow at once for a number of classes or somehow call it so as not to copy-paste it everywhere?
I tried to write separately, and call it as a function, but it doesn't work out like that.
Here is the clean method just in case:
def clean_images(self):
self.cleaned_data["images"].name = get_name_datetime(
self.cleaned_data["images"].name
)
return self.cleaned_data["images"]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question