Django 1.8.1, DB router and get_absolute_url()

45 views
Skip to first unread message

Davide Setti

unread,
May 20, 2015, 10:22:45 PM5/20/15
to django...@googlegroups.com
Hi all,
I'm using Django 1.8.1 with some models on a legacy DB. They all are in the same app, so the router is simple:

class MyRouter(object):
MYAPP = 'pkmain'

def db_for_read(self, model, **hints):
if model._meta.app_label == self.MYAPP:
return 'other_db'
return None

And similar for other Router methods. Everything works fine but the View on site in the admin. The model implements:

def get_absolute_url(self):
return 'http://example.com/{}'.format(self.id)

The View on site returns:

OperationalError at /admin/r/1/8461424/

no such table: <mytable>

It seems to be looking for mytable in the wrong database. Suggestions?

Regards.

Reply all
Reply to author
Forward
0 new messages