0👍
✅
You can define your own error list class by inherting from django’s ErrorList
. See the docs for details:
Note that you’ll have to override the method to output the full HTML and can’t just replace CSS class. You could call the base method and do a string replace on “class=\”errolist\”” and return the output.
👤ars
0👍
create custom class thath extends ErrorList
class CustomErrorList(ErrorList):
def get_context(self):
return {
"errors": self,
"error_class": "your css class",
}
And add it in your form class:
class CustomForm(ModelForm):
def init(self, *args, **kwargs):
super().init(*args, **kwargs)
self.error_class = CustomErrorList
- [Django]-Optimizing djangos count() method
- [Django]-NoReverseMatch: with arguments '()' and keyword arguments
- [Django]-My virtual environment is having access to global packages
- [Django]-Should I use JWT or Sessions for my eCommerce website?
Source:stackexchange.com