These errors happen because current_user
has the LocalProxy type, while mongo is looking for a reference. While current_user
in many ways works the same way as the actual Member
object it proxies for, it can't be used as a reference because there is no information about the reference collection for mongo to use as a DBRef.
If you want to avoid Member.objects.get(id=current_user.id) to get the actual object, you can just get the get the actual Member
object from current_user
:
new_post.author = current_user._get_current_object()
or just the DBRef
:
new_post.author = current_user.to_dbref()