标签: django-contrib

django:来自django.contrib.auth的测试失败

当我运行我的django测试时,我得到以下错误,这些错误在我的测试套件之外:

======================================================================
ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 160, in test_known_user
    super(RemoteUserCustomTest, self).test_known_user()
  File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 67, in test_known_user
    self.assertEqual(response.context['user'].username, 'knownuser')
TypeError: 'NoneType' object is unsubscriptable

======================================================================
ERROR: test_last_login (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 87, in test_last_login
    self.assertNotEqual(default_login, response.context['user'].last_login)
TypeError: 'NoneType' object is unsubscriptable

======================================================================
ERROR: test_no_remote_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 33, in test_no_remote_user
    self.assert_(isinstance(response.context['user'], AnonymousUser))
TypeError: 'NoneType' object is unsubscriptable

======================================================================
ERROR: …
Run Code Online (Sandbox Code Playgroud)

testing django django-contrib django-authentication

5
推荐指数
1
解决办法
1708
查看次数

Django - get_current_site(request) 只是抓取 example.com

我的 Django 项目正在与第三方论坛合作。正在通过 发送activation_email get_current_site(request)。密码休息是由password_resetdjango.contrib.auth.views import.

对于另一个应用程序,我需要安装django.contrib.sites. 通过这get_current_site(request)并没有给我当前的站点,而是从django.contrib.sites.models. 问题是:

  • 激活邮件确实有错误的域(example.com)
  • 当我更改代码中的 activation_mail 发件人时,密码重置邮件仍然带有“example.com”,因为它使用的是 django built_in 方式。

我的项目已经上线了。所以我想我可以删除example.com并添加我的域名。但是现在我无法再登录,并且出现此错误: django.contrib.sites.models.DoesNotExist: Site matching query does not exist.

django django-contrib python-3.x

5
推荐指数
1
解决办法
2595
查看次数

我应该使用Django的contrib应用程序还是构建自己的应用程序?

Django应用程序具有自己的功能和设计.如果您的要求与contib应用程序的功能不完全匹配,则最终会自定义和调整应用程序.我觉得这比仅仅构建自己的应用程序以满足您的需求需要更多的努力.

你怎么看?

python django django-contrib

3
推荐指数
2
解决办法
265
查看次数

消息框架:没有模块消息

我正在关注本教程:

http://docs.djangoproject.com/en/dev/ref/contrib/messages/

但我得到这个错误:

Error: No module named messages
Run Code Online (Sandbox Code Playgroud)

.

并且在django/contrib文件夹中有效地没有消息应用程序.

我如何获得工作消息框架?

django django-apps django-contrib

2
推荐指数
1
解决办法
5909
查看次数

在Django中为GeoIP2创建项目设置

我正在尝试使用GeoIP2 for Django,它要求您在设置中设置国家和城市数据集的路径GEOIP_PATH.我的问题是我不知道我应该把这个设置放在哪里,以便像Python shell这样的东西可以看到它.

我假设它会进入settings.py,但我不确定这个特定模块的语法,并且Django文档是关于此的绝对垃圾.

python django geolocation django-contrib

2
推荐指数
1
解决办法
1892
查看次数

Django,BigIntegerField和django.contrib.auth.user.id

Django现在提供了一个在Django模型中使用的BigIntegerField(可在svn trunk和1.2 alpha-1版本中使用)。

我需要django.contrib.auth.user模型具有一个BigIntegerField作为其自动递增主键,而当前它使用一个自动递增的IntegerField作为其主键。另外,无论在哪里contrib.auth.user用作ForeginKey,也都必须是BigIntegerField。

实现此目标的最佳和最安全的方法是什么?

django biginteger django-contrib

0
推荐指数
1
解决办法
3202
查看次数