-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
66 lines (49 loc) · 1.41 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from django.shortcuts import render
from django.db import models
#import GeoIP
from django.contrib.gis.geoip.base import GeoIP
#gi.country_name_by_addr('64.233.161.99')
#g =geoip()
def homepage(request):
if request.user.is_authenticated():
#g = geoip.HAS_GEOIP
g = GeoIP()
ip = request.META.get('REMOTE_ADDR', None)
if ip == '127.0.0.1':
city='Seoul'
if ip:
city = g.city(ip)
if ip == '127.0.0.1':
city=city
elif city == None:
city= 'Seoul'
else:
city = city['city']
if city == None:
city= 'Seoul'
else:
city = 'New York' # default city
request.city = city
request.ip = ip
return render(request, "dashboard.html")
else:
#g = geoip.HAS_GEOIP
g = GeoIP()
ip = request.META.get('REMOTE_ADDR', None)
if ip == '127.0.0.1':
city='Seoul'
if ip:
city = g.city(ip)
if ip == '127.0.0.1':
city=city
elif city == None:
city= 'Seoul'
else:
city = city['city']
if city == None:
city= 'Seoul, KR'
else:
city = 'New York' # default city
request.city = city
request.ip = ip
return render(request, "homepage.html")