Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
8 Відповіді
8377 Переглядів

Am trying to track the visitor ip address ,but am failed to  implement it..please help me...Urgent.

Аватар
Відмінити
Найкраща відповідь

Hi,

You can try the below code:

if "HTTP_X_FORWARDED_FOR" in request.httprequest.environ:
    # Virtual host
    ip = request.httprequest.environ["HTTP_X_FORWARDED_FOR"]
elif "HTTP_HOST" in request.httprequest.environ:
    # Non-virtualhost
    ip = request.httprequest.environ["REMOTE_ADDR"]


Hope this could helps

Аватар
Відмінити
Автор

I got Exception 'object unbound'

Can you paste your code ..

Автор

from openerp.http import request

def git_ip():

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

Автор

from openerp.http import request

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

Автор

from openerp.http import request

def get_ip():

ipnew = request.httprequest.environ['REMOTE_ADDR']

return ipnew

May be you're missing @http.rout decorator. Btw from where you're calling your method ?

Related Posts Відповіді Переглядів Дія
7
лип. 24
27658
10
черв. 21
40315
1
бер. 18
9406
1
бер. 15
6282
0
бер. 15
4053