嗨,我一直收到错误
ImportError at /account/signup/
cannot import name username_field
Request Method: GET
Request URL: http://localhost:8000/account/signup/
Django Version: 1.5.1
Exception Type: ImportError
Exception Value:
cannot import name username_field
Exception Location: /usr/local/lib/python2.7/dist-packages/tastypie /authentication.py in <module>, line 13
虽然我无法解决此问题,但我已查看此修复程序here 。当我导入引用tastypie的东西时发生错误,因此我无法修改它。我很感激你的时间来看待这个。资源文件中出现错误的代码是:
from models import *
from tastypie.resources import ModelResource
# Resources specific for structures and are location based.
class NotificationResource (ModelResource):
class Meta:
queryset = Notification.objects.all()
allowed_methods = ['get']
在我安装的应用程序设置中,我有这个。
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'tastypie',
#Local Apps
'useraccounts',
)
答案 0 :(得分:0)
为了解决这个问题,我将手浸入了tastypie代码并添加了
username_field ='username'
第19行之后的。如果发生了错误配置的错误,则会发现没有找到对用户名对象的引用这一事实导致的错误。