I get an AttributeError: type object 'Person' does not have the '_meta' attribute when trying to use Neomodel with a Django ModelForm. I am new to using neomodel and don’t know if Neomodel supports model forms, but I was looking for documents here for links with no luck either.
The first question, therefore: does Neomodel support model forms?
The second question (if the answer is yes at first): what is wrong with the following?
Models.py
from neomodel import (StructuredNode, StringProperty, IntegerProperty, RelationshipTo)
class Person (StructuredNode):
email = StringProperty(unique_index=True, required=True)
name = StringProperty(unique_index=False, required=True)
and my forms.py:
from django.forms import ModelForm
from .models import Person
class AddPersonForm(ModelForm):
class Meta:
model = Person
fields = ['email','name']
When testing this in the django shell, I get the following:
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'
I am using Python 3.4.2, Django 1.7.7 and neomodel 1.0.2
Thank!
source
share