A query on db.Model retrieves all the properties of db.Model, whether they are needed or not. Is there an alternative?

I have a db.Model that has several properties, as described below:

class Doc(db.Model): 
    docTitle = db.StringProperty(required=True)
    docText = db.TextProperty()
    docUser = db.UserProperty(required=True)
    docDate = db.DateTimeProperty(auto_now_add=True)

In the template, I simply list the names of these documents as links. For this purpose, I use the following query:

docList = Doc.gql("WHERE docUser = :1 ORDER BY docDate DESC", user)

As you can see, docList includes all properties (including "TextProperty"). However, I just use its docTitle and key () in my opinion.

Is there an alternative way to get only the requested model class attributes?

If not, should the PolyModel classes be used to distinguish between the listing and the actual use of the Doc model class by creating another model class for the docText property?

EDIT: I use the webapp web framework in the google engine ...

+3
1

App Engine , , . RPC , .

, , . (, , ) PolyModel, - , "" "".

+1

Source: https://habr.com/ru/post/1786914/


All Articles