增加ip地址记录

sh_branch
liangliang 5 years ago
parent 4ca514b842
commit 6a5ef6c8f0

@ -31,7 +31,7 @@ class OnlineMiddleware(object):
start_time = time.time()
response = self.get_response(request)
http_user_agent = request.META.get('HTTP_USER_AGENT', '')
ip = get_client_ip(request)
ip, _ = get_client_ip(request)
if 'spider'.upper() not in http_user_agent.upper():
try:
cast_time = time.time() - start_time

@ -11,6 +11,7 @@ from django.conf import settings
from django.urls import reverse
from django.utils import timezone
import os
from django.core.management import call_command
# Create your tests here.
@ -196,3 +197,11 @@ class ArticleTest(TestCase):
def test_errorpage(self):
rsp = self.client.get('/eee')
self.assertEqual(rsp.status_code, 404)
def test_commands(self):
call_command("ping_baidu", "all")
call_command("create_testdata")
call_command("clear_cache")
call_command("build_index")
call_command("build_search_words")
call_command("sync_user_avatar")

Loading…
Cancel
Save