How to make the objects.filter method to work with a custom field/model that takes in dictionaries?
===

I created a custom field that allows the user to pass in a dictionary. This dictionary gets saved as a string in my database. Here is the main part of my models.py class. 

    class OptionsField(models.Field):
        description = 'All options'
        #__metaclass__ = models.SubfieldBase
        
        def __init__(self, *args, **kwargs):
            kwargs['max_length'] = 2048
            kwargs['unique'] = False
            kwargs['null'] = True 
            super(OptionsField, self).__init__(*args, **kwargs) 
            
        def db_type(self, connection):
            return 'varchar(2048)'
            
        #Transforms database values to a python dictionary     
        def to_python(self, value): 
            if isinstance(value, dict):
                return value
            together = value.split(' \n')
            returnDictionary = {}
            for item in together:
                dictionaryField = item.split(' : ')
                returnDictionary[dictionaryField[0]] = dictionaryField[1]
            return returnDictionary
            
        #Transforms a python dictionary to database-compatible values (string)    
        def get_prep_value(self, dict): 
            databaseList = [] 
            print dict
            for key, value in dict.iteritems():
                listValue = ' : '.join([str(key), str(value)])
                databaseList.append(listValue)
            databaseList.sort()
            return ' \n'.join(databaseList) 
    -------------------------------END OF CUSTOM FIELD---------------------
            
    class MyModel(models.Model):
        options = OptionsField()
        
        class Meta:
            app_label = 'testingDB' 


And inside my main, I can do the following

    dictionary = {'a':'b', 'c':'d'}
    example = MyModel(options = dictionary) 
    example.save() 
    
    example.options['ZZ'] = 'z'
    example.options['a'] = 'grr'
    
    example.save()

The first save puts the following in the database:

    +----+--------+
    | id | options| 
    +----+--------+
    |  1 | a : b  |  
    |    | c : d  | 
    +----+--------+

The second save changes the above to:

    +----+--------+
    | id | options| 
    +----+--------+
    |  1 | a : grr|  
    |    | c : d  | 
    |    | ZZ : z |
    +----+--------+    


How do I search in this database though? If I do something like 
`test=MyModel.objects.filter(options['a'] = 'b')`

I get a `SyntaxError: Keyword can't be an expression` 
I assume I have to make the method get_prep_lookup, and I've tried a bunch of things, but it doesn't seem to work. 

Documentation: https://docs.djangoproject.com/en/1.4/howto/custom-model-fields/