1

I'm having real issues figuring out how to setup Neomodel to work. I have defined my classes in a models.py and I'm importing them but all I ever get is a...

ClassAlreadyDefined: Class models.Album with labels Album already defined: {frozenset({'Album'}): <class 'models.Album'>}

error. Here's what my code looks like for example:

from neomodel import StructuredNode, StringProperty, DateTimeProperty, IntegerProperty, UniqueIdProperty, RelationshipTo, RelationshipFrom

    
class Album(StructuredNode):
    uid = UniqueIdProperty()
    band = StringProperty()
    name = StringProperty()
    url = StringProperty()
    band_name = StringProperty()
    year = IntegerProperty()
    
    genres = RelationshipTo('Genre', 'TAGGED')
    fans = RelationshipFrom('Fan', 'BOUGHTBY')
Trevor Fox
  • 31
  • 2
  • Do you have the rest of your code where the error is appearing? It sounds like you are defining two Album classes – Steve Mapes Aug 24 '21 at 12:05

1 Answers1

1

Restarting the python kernel fixes the problem. The problem is that the first time you run, the class definition goes into the neomodel registry, subsequent runs think you are redefining the class.

There is probably a simpler fix, some flag that says we are doing development and testing, but not sure what that is.

Swami
  • 11
  • 1