summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Koziel <arthur@arthurkoziel.com>2010-08-15 22:02:04 +0000
committerArthur Koziel <arthur@arthurkoziel.com>2010-08-15 22:02:04 +0000
commit2f027bf5dd4b92c7fcb325a1cea2abcabcfa2c90 (patch)
tree14be5d7a4c011eafaae71302ab85bdcbb6b612a8
parenta357ed10be8eb7d9c0210a47e28b28c2653739ed (diff)
downloaddjango-2f027bf5dd4b92c7fcb325a1cea2abcabcfa2c90.tar.gz
[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
-rw-r--r--django/core/apps.py3
-rw-r--r--django/db/models/options.py6
2 files changed, 6 insertions, 3 deletions
diff --git a/django/core/apps.py b/django/core/apps.py
index ae01b44e7f..faec0886fd 100644
--- a/django/core/apps.py
+++ b/django/core/apps.py
@@ -25,6 +25,7 @@ class App(object):
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 @@ class AppCache(object):
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:
diff --git a/django/db/models/options.py b/django/db/models/options.py
index 5d84ab6472..65aa8cadb1 100644
--- a/django/db/models/options.py
+++ b/django/db/models/options.py
@@ -2,6 +2,7 @@ import re
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 @@ class Options(object):
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):