1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Made inspectdb tests deal with a smaller generated models.py file.

Implemented this by adding a stealth table_name_filter option for the
command.
This commit is contained in:
Ramiro Morales
2012-06-01 20:58:53 -03:00
parent 939af5a654
commit 72130385bf
2 changed files with 32 additions and 2 deletions

View File

@@ -26,6 +26,8 @@ class Command(NoArgsCommand):
def handle_inspection(self, options):
connection = connections[options.get('database')]
# 'table_name_filter' is a stealth option
table_name_filter = options.get('table_name_filter')
table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '').replace('-', '')
@@ -43,6 +45,9 @@ class Command(NoArgsCommand):
yield ''
known_models = []
for table_name in connection.introspection.table_names(cursor):
if table_name_filter is not None and callable(table_name_filter):
if not table_name_filter(table_name):
continue
yield 'class %s(models.Model):' % table2model(table_name)
known_models.append(table2model(table_name))
try: