8000 [soc2010/app-loading] use the db_prefix attribute to create database … · alex-python/django@2f027bf · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f027bf

Browse files
committed
[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
1 parent a357ed1 commit 2f027bf

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

django/core/apps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, name):
2525
self.name = name
2626
self.verbose_name = _(name.title())
2727
self.verbose_name_plural = _(name.title())
28+
self.db_prefix = name
2829
self.errors = []
2930
self.models = []
3031
self.module = None
@@ -201,7 +202,7 @@ def get_app(self, app_label, emptyOK=False):
201202
self._populate()
202203
self.write_lock.acquire()
203204
try:
204-
for app_name in settings.INSTALLED_APPS:
205+
for app_name in self.installed_apps:
205206
if app_label == app_name.split('.')[-1]:
206207
mod = self.load_app(app_name, False)
207208
if mod is None:

django/db/models/options.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from bisect import bisect
33

44
from django.conf import settings
5+
from django.core.apps import cache
56
from django.db.models.related import RelatedObject
67
from django.db.models.fields.related import ManyToManyRel
78
from django.db.models.fields import AutoField, FieldDoesNotExist
@@ -95,9 +96,10 @@ def contribute_to_class(self, cls, name):
9596
self.verbose_name_plural = string_concat(self.verbose_name, 's')
9697
del self.meta
9798

98-
# If the db_table wasn't provided, use the app_label + module_name.
99+
# If the db_table wasn't provided, use the db_prefix + module_name.
99100
if not self.db_table:
100-
self.db_table = "%s_%s" % (self.app_label, self.module_name)
101+
app_instance = cache.find_app(se 4E7C lf.app_label)
102+
self.db_table = "%s_%s" % (app_instance.db_prefix, self.module_name)
101103
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
102104

103105
def _prepare(self, model):

0 commit comments

Comments
 (0)
0