Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin actions in a changelist from search don't work #17

Open
smeyfroi opened this issue Feb 14, 2012 · 0 comments
Open

Admin actions in a changelist from search don't work #17

smeyfroi opened this issue Feb 14, 2012 · 0 comments

Comments

@smeyfroi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant