获取ip

    if request.META.has_key('HTTP_X_FORWARDED_FOR'):
        ip_c =  request.META['HTTP_X_FORWARDED_FOR']
    else:
        ip_c = request.META['REMOTE_ADDR']

判定ip是否在数据库中,进行不同处理

    ip_exist = Result.objects.filter(ip__contains = str(ip_c))  #ip代表数据库字段 Result为model名称(数据库表名)
    if ip_exist:
        pass
    else:
        pass
https://www.douban.com/note/301166150/

相关文章:

  • 2021-08-11
  • 2021-05-29
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2021-04-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案