I'm pretty new to Django/Python and having a bit of trouble sorting this out.
我是Django/Python的新手,在解决这个问题上有点困难。
Ubuntu 14.04 Apache Django 1.7.4 python 2.7 Postgresql
Ubuntu 14.04 Apache Django 1.7.4 python 2.7 Postgresql。
__init__() got an unexpected keyword argument 'hints'
Request Method: GET
Request URL: http://localhost/
Django Version: 1.7.4
Exception Type: TypeError
class Tier(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=100)
class Recipe(models.Model):
id = models.UUIDField(auto_add=True, primary_key=True, default=uuid.uuid4)
name = models.CharField(max_length=100)
tier = models.ForeignKey(Tier)
Here is the code being executed, errors on trying to retrieve the tier id.
这是正在执行的代码,在试图检索层id时出错。
firstRecipe = Recipe.objects.first()
tierId = firstRecipe.tier.id
My database tables are
我的数据库表
web_recipe
id
name
tier_id
web_tier
id
name
Stacktrace
加亮
Traceback:
File "/home/user123/daoresources/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/user123/daoresources/web/views.py" in index
7. firstRecipe = Recipe.objects.first()
File "/home/user123/daoresources/env/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
92. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/user123/daoresources/env/lib/python2.7/site-packages/django/db/models/query.py" in first
508. qs = self if self.ordered else self.order_by('pk')
File "/home/user123/daoresources/env/lib/python2.7/site-packages/django/db/models/query.py" in order_by
812. obj = self._clone()
File "/home/user123/daoresources/env/lib/python2.7/site-packages/django/db/models/query.py" in _clone
955. c = klass(model=self.model, query=query, using=self._db, hints=self._hints)
Exception Type: TypeError at /
Exception Value: __init__() got an unexpected keyword argument 'hints'
Environment:
环境:
Django Version: 1.7.4
Python Version: 2.7.6
Installed Applications:
('web', 'django_pg')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
EDIT: I ended up just saying screw it and converted my project over to mysql and everything works fine. If someone comes up with an valid answer I will test it on a new formed project and mark it as correct.
编辑:最后我只是说,把我的项目转换成mysql,一切都很好。如果有人提出一个有效的答案,我会在一个新形成的项目上测试它,并把它标记为正确。
1 个解决方案
#1
1
Install the latest version of django-pgfields from git. It fixed it for me.
从git安装django-pgfields的最新版本。它帮我修好了。
If you install from requirements file then remove 'django-pgfields' and add
如果从需求文件安装,则删除“django-pgfields”并添加
-e git://github.com/lukesneeringer/django-pgfields.git#egg=django-pgfields
#1
1
Install the latest version of django-pgfields from git. It fixed it for me.
从git安装django-pgfields的最新版本。它帮我修好了。
If you install from requirements file then remove 'django-pgfields' and add
如果从需求文件安装,则删除“django-pgfields”并添加
-e git://github.com/lukesneeringer/django-pgfields.git#egg=django-pgfields