[Fixed]-Check for a 'unique_together' in a conditional sentence

1👍

You can do this

def MyViewTwo(request):
    # note you shouldn't use flat=true here
    varlist = MyModel.objects.filter().values_list('fieldone','fieldtwo')
    if not (fieldonevalue, fieldtwovalue) in varlist:
        # Do something

Leave a comment