Skip to content

Expose model with QuerySet.model which works with Django QuerySet #792

@debugger22

Description

@debugger22
In [6]: from django.contrib.auth.models import User

In [7]: User.objects.all().model
Out[7]: django.contrib.auth.models.User

In [8]: type(User.objects.all())
Out[8]: django.db.models.query.QuerySet

In [9]: type(MongoUser.objects.all())
Out[9]: mongoengine.queryset.queryset.QuerySet

In [10]: MongoUser.objects.all().model
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-846b78ff429d> in <module>()
----> 1 MongoUser.objects.all().model

AttributeError: 'QuerySet' object has no attribute 'model'

Here MongoUser is a Document class and User is a simple user model from django.contrib.auth.
This is necessary to make it work with dhango-rest-framework library.

Thanks for all the great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions