summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-01-28 10:21:07 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-01-28 10:21:07 +0100
commitc47fa3b4814240bb47342a4446d40ea83bd3ed19 (patch)
tree5beed3ce7d9d0262bd6287a569ff0de35533f446 /django
parentf46d7314b50d71a75f51ebae9c5957cb96b11bd9 (diff)
Fixed #19676 -- Supported 'self' foreign keys in inspectdb.
Thanks Georgy Kutsurua for the report and Simon Charette for the patch.
Diffstat (limited to 'django')
-rw-r--r--django/core/management/commands/inspectdb.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py
index 936d5e89ab..443312c66d 100644
--- a/django/core/management/commands/inspectdb.py
+++ b/django/core/management/commands/inspectdb.py
@@ -6,7 +6,7 @@ from optparse import make_option
from django.core.management.base import NoArgsCommand, CommandError
from django.db import connections, DEFAULT_DB_ALIAS
-from django.utils import six
+
class Command(NoArgsCommand):
help = "Introspects the database tables in the given database and outputs a Django model module."
@@ -34,7 +34,7 @@ class Command(NoArgsCommand):
table_name_filter = options.get('table_name_filter')
table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '').replace('-', '')
- strip_prefix = lambda s: s.startswith("u'") and s[1:] or s
+ strip_prefix = lambda s: s[1:] if s.startswith("u'") else s
cursor = connection.cursor()
yield "# This is an auto-generated Django model module."
@@ -86,7 +86,7 @@ class Command(NoArgsCommand):
extra_params['unique'] = True
if is_relation:
- rel_to = relations[i][1] == table_name and "'self'" or table2model(relations[i][1])
+ rel_to = "self" if relations[i][1] == table_name else table2model(relations[i][1])
if rel_to in known_models:
field_type = 'ForeignKey(%s' % rel_to
else: