[Answer]-Tastypie FormValidation error message

1👍

Turns out django-angular doesn’t play well with TastyPie. After some debugging, I found out that their TupleErrorList didn’t correctly render ValidationErrors. Fixed class:

from django.forms.utils import ErrorList
from django.core.exceptions import ValidationError
from djangular.forms.angular_base import TupleErrorList

class FixedTupleErrorList(TupleErrorList, ErrorList):
    def __getitem__(self, i):
        """
        This method was missing in django-angulars TupleErrorList
        (don't know why they didn't inherit from the default django ErrorList)
        """
        error = self.data[i]
        if isinstance(error, ValidationError):
            return list(error)[0]
        return error # originally, there was force_text here, but it forced unicode prefixes around strings

Leave a comment