You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is complicated to explain, but worth having documented somewhere for the next person.
I have a reasonably complex project built on nonrel/GAE that uses the admin screens quite a bit. There are some constraints in what's possible since the built-in admin logic assumes an underlying relational database. But it's definitely possible to get something quite functional working.
However, there's a problem with executing an 'admin action' (https://docs.djangoproject.com/en/1.3/ref/contrib/admin/actions/) against selected entitities in a change list that's the result of a search. Searches can be made to work with the appropriate dbindexer setup, but there's a weird bit of logic in the vanilla-django code that creates a queryset of selected entities from the search results that causes problems.
The first set of problems comes from djangotoolbox.db.basecompiler.EMULATED_OPS, where the emulated operations don't handle operations against dbindexer list columns. You can get round that like this (or on one line probably):
def _list_starts_with(l, s):
return reduce(lambda result, item: result or item.startswith(s), l)
But then you get an error later on when the action tries to do query set.update. It's complicated and I don't have a fix so there's no point discussing.
Anyway, the upshot of all that is that you probably can't do "admin actions" using nonrel if you enable searching a changelist, unless you'rre prepared to do some changes to vanilla django somewhere along the way... I don't suppose it should be very complicated since the selected entities could be specified with a list of IDs, but that isn't what's going on: that list of IDs is somehow overlaid on a query set that is related to the search you've done. Dunno why. Seems a bit weird to me. Anyway. For info.
Steve
The text was updated successfully, but these errors were encountered:
This is complicated to explain, but worth having documented somewhere for the next person.
I have a reasonably complex project built on nonrel/GAE that uses the admin screens quite a bit. There are some constraints in what's possible since the built-in admin logic assumes an underlying relational database. But it's definitely possible to get something quite functional working.
However, there's a problem with executing an 'admin action' (https://docs.djangoproject.com/en/1.3/ref/contrib/admin/actions/) against selected entitities in a change list that's the result of a search. Searches can be made to work with the appropriate dbindexer setup, but there's a weird bit of logic in the vanilla-django code that creates a queryset of selected entities from the search results that causes problems.
The first set of problems comes from djangotoolbox.db.basecompiler.EMULATED_OPS, where the emulated operations don't handle operations against dbindexer list columns. You can get round that like this (or on one line probably):
def _list_starts_with(l, s):
return reduce(lambda result, item: result or item.startswith(s), l)
...
'startswith': lambda x, y: _list_starts_with(x, y) if isinstance(x, (list,tuple)) else x.startswith(y),
...
But then you get an error later on when the action tries to do query set.update. It's complicated and I don't have a fix so there's no point discussing.
Anyway, the upshot of all that is that you probably can't do "admin actions" using nonrel if you enable searching a changelist, unless you'rre prepared to do some changes to vanilla django somewhere along the way... I don't suppose it should be very complicated since the selected entities could be specified with a list of IDs, but that isn't what's going on: that list of IDs is somehow overlaid on a query set that is related to the search you've done. Dunno why. Seems a bit weird to me. Anyway. For info.
Steve
The text was updated successfully, but these errors were encountered: