Skip to content

Bug fix #68

Open
Open
@Lord-Evil

Description

@Lord-Evil

First time I'm trying to use MongoDB with Django.
Error in your module.. boom!

/usr/lib/python3.4/site-packages/djangotoolbox/db/base.py in _value_for_db_collection(self, value, field, field_kind, db_type, lookup)
    481                 # "list" may be used for SetField.
    482                 #print("Type: "+str(db_type))
--> 483                 if db_type in 'list':
    484                     return list(value)
    485                 elif db_type == 'set':

TypeError: 'in <string>' requires string as left operand, not NoneType

When trying to create ListField() in the model as per example.
3-4 hours of debugging step by step brought me to this solution:

class NonrelDatabaseWrapper(BaseDatabaseWrapper):
   data_types={'ListField':'list'}

Next step is to solve this crap:

/usr/lib/python3.4/site-packages/django/db/models/fields/__init__.py in get_prep_value(self, value)
    983         if value is None:
    984             return None
--> 985         return int(value)
    986 
    987     def contribute_to_class(self, cls, name, **kwargs):

TypeError: int() argument must be a string, a bytes-like object or a number, not 'ObjectId'

When saving the actual model.

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