Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors NotRegistered flask-mongoengine Tutorial

I started this Turial, Here

And get this error

**mongoengine.errors.NotRegistered:** `Comment` has not been registered in the document registry. Importing the document class automatically registers it, has it been imported?

any idea. Thank you So much.

like image 200
juvasquezg Avatar asked Apr 08 '15 16:04

juvasquezg


2 Answers

Just place the Comment Model above the Post Model, since the Comment Model is being referenced in the Post Model

like image 104
i_emmanuel Avatar answered Nov 15 '22 21:11

i_emmanuel


First register all your models some where like __init__.py file in your models package.

Then you can use get_document('Comment') function (which is imported from mongoengine.base.common) instead of importing your models in each other scripts to avoid circular imports and exceptions like mongoengine.errors.NotRegistered

like image 43
hamidfzm Avatar answered Nov 15 '22 20:11

hamidfzm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!