Check the multiplicity of a 'field' for an object.

def check_field_multiplicity(tag, previous_tags):
    """
    Check the multiplicity of a 'field' for an object.
    """
    fail = False
    #If the field is single
    if not tag.field.multiple:
        #If the tag is being created...
        if not tag.id:
            #... and the new field was already included in the previous tags,
            #fail
            fail = previous_tags.filter(field=tag.field)
        #If the tag is being modifying...
        else:
            #... but there is only one previous tag (the one that is being
            #modifying), do not fail
            fail = previous_tags.filter(field=tag.field).count() > 1
    return fail