Django在访问索引页面时计算访客用户

时间:2015-12-21 22:29:57

标签: python django django-views

在Django 访问index.html时如何计算访客用户

我的Django版本是1.8.2

请帮帮我?

嗨我做pip install django-tracking然后migrate但是我收到了这个错误

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/roshandel/vroshan/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/opt/roshandel/vroshan/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
    django.setup()
  File "/opt/roshandel/vroshan/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/opt/roshandel/vroshan/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/opt/roshandel/vroshan/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/opt/roshandel/vroshan/lib/python2.7/site-packages/tracking/models.py", line 5, in <module>
    from django.contrib.gis.utils import HAS_GEOIP
ImportError: cannot import name HAS_GEOIP

我该如何解决?

1 个答案:

答案 0 :(得分:2)

事实上,提供网站分析可以使用不同的3rd party package。但由于您只需要访问者统计信息,以下内容可以为您提供帮助; django-trackingdjango-visitordjango-statistics。但是在检查了 django-statistics reposiotry之后,它似乎将以前的包作为依赖关系,这意味着它是两者的一种包装,但正如我看到的最后一个贡献是3年前,而django-tracking的最后一次贡献仅仅是3个月前。所以我会推荐 django-tracking

 pip install django-tracking

<强> settings.py

INSTALLED_APPS = (
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        ...
        'tracking',
        ...
    )

<强>迁移

python manage.py migrate

有关更多配置,请查看README