crucialfelix/django-ajax-selects — Issue #3: non operation with mongodb
Author: douglaskastle
Created: 2012-03-03 01:07:08+00:00
State: open

Hi there

I have been using ajax-selects for a few days now, and I am very impressed.

I am also investigating django integration with mongodb via django-nonrel. There are a lot of django work that just don't work with this, ajax-selects is one of them. However after investigating this boiled down to the fact that it expects the 'id' field of models to be an integer, however the id's used in mongodb are strings, of the type '4f4de9d23cc2a30a23000010'.

After looking through your code I found that it is explicitly casting the id returned to, in one case a long:
ajax_select/fields.py, line 77,
```
return long(got)
```
and to an int:
ajax_select/__init__.py line 49
```
ids = [int(id) for id in ids]
```
After I made the mods, which removed the casting to integers it then succesfully worked with mongodb via the admin interface, with one caveat, after you have entered a value via the make_ajax_form interface and re-enter the model entry again via the admin interface it doesn't show the value that had been chosen, it is just blank, even though if you check the contents of the database it is still there. My guess the prefetch of the admin is also sensitive to integers.

I understand if you think it is not worth supporting, I am merely reporting my observation in case you do. My interest in ajax-selects stems from trying to traverse a very big database that mongodb is designed to handle.