On Sun, Dec 6, 2009 at 12:35 AM, Simon Willison <si...@simonwillison.net> wrote: > On Dec 5, 4:20 pm, Russell Keith-Magee <freakboy3...@gmail.com> wrote: >> Trust me - I don't want to do mindless busy work. However, we need to >> have some sort of answer for the admin interface - Django's admin is a >> big selling point for Django for some people, so we can't really >> introduce a huge new feature, and then say "but you can't use it in >> admin". I'm interested in making the least intrusive change that is >> possible without hamstringing future multi-db interfaces. > > It strikes me that the admin issue should be solvable entirely in > django.contrib.admin without any changes to the multidb code itself. > Right now you can get most of the job done using a ModelAdmin > subclass: > > from django.contrib import admin > from blog.models import Entry > > class EntryAdmin(admin.ModelAdmin): > def save_model(self, request, obj, form, change): > obj.save(using='otherdb') > > def queryset(self, request): > return Entry.objects.using('otherdb').all() > > admin.site.register(Entry, EntryAdmin) > > I haven't tested the above so it's probably missing a few cases > (save_fieldsets for example perhaps) but if we document it I think > it's a good enough solution for the moment. Even if we need to > refactor ModelAdmin a bit to ensure the right hooks are available it > still shouldn't be a massive change.
I want to poke around this code over the next couple of days. I suspect that you're probably right - the set of changes won't be too significant. However, if it is possible to provide a simple configuration option so that end-users don't have to write boilerplate save_model() and queryset() definitions, I think that's worth looking into. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.