Skip to content

Commit 5d196b7

Browse files
committed
show visitor country if city is None
1 parent ed8c287 commit 5d196b7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

apps/blog/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def get_context_data_all(**kwargs):
7575
for visitor in visitor_ip:
7676
ip_split = visitor.ip.split('.')
7777
visitor.ip = '%s.*.*.%s' % (ip_split[0], ip_split[3])
78+
if not visitor.city:
79+
visitor.city = visitor.country
7880
kwargs['visitor_ip'] = visitor_ip
7981
kwargs['visitor_num'] = cache.get('visitor_num')
8082
recent_comment = BlogComment.objects.order_by('-created_time')[:5]

0 commit comments

Comments
 (0)