I am very new to pymodm, and I am stuck on trying to create a one to many linking using the models included with pymodm. Here is my example code:
connect(f"mongodb://{ip}:{port}/{db_name}", alias='inventory')
class add_as_reference(fields.ReferenceField):
name = fields.CharField
class Meta:
connection_alias='inventory'
class hold_many_references(MongoModel):
name = fields.CharField
my_refs = fields.ListField(add_as_reference)
class Meta:
connection_alias='inventory'
This fails, with the error:
ValueError: field must be an instance of MongoBaseField, not <class ‘pyuniti.common.lib.inventory.inventory.InventoryDB_API.open_db..add_as_reference’>
I see that you must make this an instance of MongoBaseField, but how can I do that, but have the list hold references to other documents?
Any help would be greatly appriecated.