[Django]-AttributeError: 'QuerySet' object has no attribute 'add'

4πŸ‘

βœ…

I don’t think so you can do it like this.
QuerySet can be thought of as an extension of list but it is not the same.

If you need to return the colors you can do it like this.

def get_colors(*args, **kwargs):
    colors = []
    for paint in Paint.objects.all():
        if paint.color and paint.color not in colors:
            colors.append(paint.color)
    return colors
πŸ‘€Bipul Jain

Leave a comment