Hey, I want to use a coalesce-expression as orderBy-criteria in an admin- list-view. It seems to be easy with the following definition in the model:
<code> def end_extra(self, obj): return obj.endprj if obj.extraprj is None else obj.extraprj end_extra.short_description="end/extratime" end_extra.admin_order_field="coalesce(endprj, extraprj)" </code> With this definition I can put the "field" end_extra in the list- display and it appears as sortable. But in django.db.models.sql.query.py, method add_ordering this raises an exception, because the ORDER_PATTERN, defined in django.db.models.sql.constants.py don't permit the ; and ()-signs. I thougth it should be easy to change this ORDER_PATTERN and tried it in the queryset-Method of the relevant admin-model: <code> from django.db.models.sql import constants MyClass(...): def queryset(self, request): constants.ORDER_PATTERN = re.compile(r'\?|[-+]?[().,\w]+ $') ... </code> But the original pattern never changed. constants is bound to the django.db.models.sql.constants-module in globals(), the debugger passes just one time at program-start the original pattern-definition. Where is my fault? Or is there another way to solve the problem without changes to the data-model? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.