Ticket #5000: table-prefix-better.diff
File table-prefix-better.diff, 2.3 KB (added by , 15 years ago) |
---|
-
django/db/models/options.py
98 98 self.verbose_name_plural = string_concat(self.verbose_name, 's') 99 99 del self.meta 100 100 101 # If the db_table wasn't provided, use the app_label + module_name. 101 prefix = getattr(settings, 'DATABASE_TABLE_PREFIX', '') 102 103 # If the db_table wasn't provided, use prefix + app_label + module_name. 104 # Otherwise, use prefix + given table name from db_table. 102 105 if not self.db_table: 103 self.db_table = "%s_%s" % (self.app_label, self.module_name) 104 self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) 106 self.db_table = "%s%s_%s" % (prefix, self.app_label, self.module_name) 107 else: 108 self.db_table = "%s%s" % (prefix, self.db_table) 109 110 self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) 105 111 106 107 112 def _prepare(self, model): 108 113 if self.order_with_respect_to: 109 114 self.order_with_respect_to = self.get_field(self.order_with_respect_to) -
django/conf/global_settings.py
131 131 DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. 132 132 DATABASE_OPTIONS = {} # Set to empty dictionary for default. 133 133 134 # Global prefix for every table created from a model in this project. 135 DATABASE_TABLE_PREFIX = '' 136 134 137 # Host for sending e-mail. 135 138 EMAIL_HOST = 'localhost' 136 139 -
docs/ref/settings.txt
227 227 The port to use when connecting to the database. An empty string means the 228 228 default port. Not used with SQLite. 229 229 230 .. setting:: DATABASE_TABLE_PREFIX 231 232 DATABASE_TABLE_PREFIX 233 --------------------- 234 235 Default: ``''`` (Empty string) 236 237 A prefix that will be added to every table name. Includes models that 238 specify a table name manually. 239 230 240 .. setting:: DATABASE_USER 231 241 232 242 DATABASE_USER