我正在尝试使用“coleifer / django-relationships”在我的网站中创建用户关系系统。但是在最开始的步骤中遇到了问题:
我按照文档,成功安装了它。然后将“关系”添加到INSTALLED_APPS中
文档告诉我下一步是运行
django-admin.py syncdb
我做到了,但有很多错误,比如:
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
所以我改为运行“python manage.py syncdb”。看来还行 然后我尝试在命令行中使用用户模型,只需按照文档(在此之前添加两个用户):
>>> john = User.objects.get(username='john')
>>> rel = john.relationships.add(jane)
这就是问题所在。
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "build/bdist.macosx-10.7-intel/egg/relationships/models.py", line 96, in add
status = RelationshipStatus.objects.following()
File "build/bdist.macosx-10.7-intel/egg/relationships/models.py", line 13, in following
return self.get(from_slug='following')
File "/Library/Python/2.7/site-packages/django/db/models/manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 349, in get
% self.model._meta.object_name)
DoesNotExist: RelationshipStatus matching query does not exist.
我发现RelationshipStatus表是空的。 我做错了吗?
答案 0 :(得分:0)
以下是答案:https://github.com/coleifer/django-relationships/issues/19
最好将源代码直接放入项目而不是安装它,这样当你运行syncdb命令时,表格将被初始化。