我得到 AttributeError:type object' Person'在尝试将Neomodel与Django的ModelForm一起使用时,没有属性' _meta' 。我不习惯使用neomodel而且不知道Neomodel是否支持模型,但是我已经搜索了文档并在这里搜索了没有运气的参考文献。
第一个问题是:Neomodel是否支持模型?
第二个问题(如果答案是肯定的话):以下是什么问题?
Models.py
from neomodel import (StructuredNode, StringProperty, IntegerProperty, RelationshipTo)
class Person (StructuredNode):
#Properties
email = StringProperty(unique_index=True, required=True)
name = StringProperty(unique_index=False, required=True)
和我的forms.py:
from django.forms import ModelForm
from .models import Person
class AddPersonForm(ModelForm):
class Meta:
model = Person
fields = ['email','name']
在django shell中进行测试时,我得到以下结果:
from devsite_neo.forms import AddPerson
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Dev\www\repos\devsite\devsite_neo\forms.py", line 7, in <module>
class AddPerson(ModelForm):
File "c:\Dev\www\venv\djangoenv\lib\site-packages\django\forms\models.py", line 284, in __new__
opts.help_texts, opts.error_messages)
File "c:\Dev\www\venv\djangoenv\lib\site-packages\django\forms\models.py", line 184, in fields_for_model
opts = model._meta
AttributeError: type object 'Person' has no attribute '_meta'
我使用的是Python 3.4.2,Django 1.7.7和neomodel 1.0.2
谢谢!