edit.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:nav 作者: UNINETT 项目源码 文件源码
def does_ip_exist(ip_addr, netbox_id=None):
    """Checks if the given IP already exist in database.

    Parameters:
     * ip_addr   - the IP addres to look for.
     * netbox_id - a netbox primary key that can have the given ip_addr, and
                   the function will still return False.

    Returns:
     - True if the IP already exists in the database (and the netbox with the
       IP is not the same as the given netbox_id).
     - False if not.
    """
    if netbox_id:
        ip_qs = Netbox.objects.filter(Q(ip=unicode(ip_addr)), ~Q(id=netbox_id))
    else:
        ip_qs = Netbox.objects.filter(ip=unicode(ip_addr))
    return ip_qs.count() > 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号