arthur.sw
arthur.sw

Reputation: 11619

Strange QuerySet in Django

I'm having bad times with QuerySets in Django 1.6.1: many methods seem to be missing, maybe replaced by others.

For example I can't use the | operator, neither the serializer (just like here), but I can use to_json which I could not find in the documentation...

This is what I obtain when I type dir(anyQuerySet) in a django console:

['_QuerySet__dereference',
'__call__',
'__class__',
'__deepcopy__',
'__delattr__',
'__dict__',
'__doc__',
'__format__',
'__getattribute__',
'__getitem__',
'__hash__',
'__init__',
'__iter__',
'__module__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'_as_pymongo',
'_as_pymongo_coerce',
'_auto_dereference',
'_class_check',
'_collection',
'_collection_obj',
'_cursor',
'_cursor_args',
'_cursor_obj',
'_dereference',
'_document',
'_ensure_indexes',
'_fields_to_dbfields',
'_get_as_pymongo',
'_get_order_by',
'_get_scalar',
'_hint',
'_initial_query',
'_item_frequencies_exec_js',
'_item_frequencies_map_reduce',
'_iter',
'_limit',
'_loaded_fields',
'_mongo_query',
'_none',
'_ordering',
'_query',
'_query_obj',
'_read_preference',
'_scalar',
'_skip',
'_slave_okay',
'_slice',
'_snapshot',
'_sub_js_fields',
'_timeout',
'_where_clause',
'all',
'all_fields',
'as_pymongo',
'average',
'clone',
'count',
'create',
'delete',
'distinct',
'ensure_index',
'exclude',
'exec_js',
'explain',
'fields',
'filter',
'first',
'from_json',
'get',
'get_or_create',
'hint',
'in_bulk',
'insert',
'item_frequencies',
'limit',
'map_reduce',
'next',
'no_dereference',
'none',
'only',
'order_by',
'read_preference',
'rewind',
'scalar',
'select_related',
'skip',
'slave_okay',
'snapshot',
'sum',
'timeout',
'to_json',
'update',
'update_one',
'values_list',
'where',
'with_id']

Upvotes: 0

Views: 132

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599610

You appear to be using MongoDb rather than a traditional relational database. So, you must also be using a third party library to query that db from Django. You shouldn't therefore be surprised that your querysets differ from the standard Django ones.

Upvotes: 2

Related Questions