Skip to content
Browse files

[soc2010/app-loading] use the db_prefix attribute to create database …

…tables

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13593 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent a357ed1 commit 2f027bf5dd4b92c7fcb325a1cea2abcabcfa2c90 @arthurk arthurk committed Aug 15, 2010
Showing with 6 additions and 3 deletions.
  1. +2 −1 django/core/apps.py
  2. +4 −2 django/db/models/options.py
View
3 django/core/apps.py
@@ -25,6 +25,7 @@ def __init__(self, name):
self.name = name
self.verbose_name = _(name.title())
self.verbose_name_plural = _(name.title())
+ self.db_prefix = name
self.errors = []
self.models = []
self.module = None
@@ -201,7 +202,7 @@ def get_app(self, app_label, emptyOK=False):
self._populate()
self.write_lock.acquire()
try:
- for app_name in settings.INSTALLED_APPS:
+ for app_name in self.installed_apps:
if app_label == app_name.split('.')[-1]:
mod = self.load_app(app_name, False)
if mod is None:
View
6 django/db/models/options.py
@@ -2,6 +2,7 @@
from bisect import bisect
from django.conf import settings
+from django.core.apps import cache
from django.db.models.related import RelatedObject
from django.db.models.fields.related import ManyToManyRel
from django.db.models.fields import AutoField, FieldDoesNotExist
@@ -95,9 +96,10 @@ def contribute_to_class(self, cls, name):
self.verbose_name_plural = string_concat(self.verbose_name, 's')
del self.meta
- # If the db_table wasn't provided, use the app_label + module_name.
+ # If the db_table wasn't provided, use the db_prefix + module_name.
if not self.db_table:
- self.db_table = "%s_%s" % (self.app_label, self.module_name)
+ app_instance = cache.find_app(self.app_label)
+ self.db_table = "%s_%s" % (app_instance.db_prefix, self.module_name)
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
def _prepare(self, model):

0 comments on commit 2f027bf

Please sign in to comment.
Something went wrong with that request. Please try again.