Ticket #13528: 13528-1.diff

File 13528-1.diff, 987 bytes (added by Claude Paroz, 12 years ago)

Possible fix

  • django/db/models/options.py

    diff --git a/django/db/models/options.py b/django/db/models/options.py
    index a302e2d..2136741 100644
    a b class Options(object):  
    7171        self.related_fkey_lookups = []
    7272
    7373    def contribute_to_class(self, cls, name):
    74         from django.db import connection
     74        from django.db import connections, router
    7575        from django.db.backends.util import truncate_name
    7676
    7777        cls._meta = self
    class Options(object):  
    119119
    120120        # If the db_table wasn't provided, use the app_label + model_name.
    121121        if not self.db_table:
     122            db = router.db_for_read(self.model)
    122123            self.db_table = "%s_%s" % (self.app_label, self.model_name)
    123             self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
     124            self.db_table = truncate_name(self.db_table, connections[db].ops.max_name_length())
    124125
    125126    @property
    126127    def module_name(self):
Back to Top