Changeset 8215 for django/branches/gis/django/core/management
- Timestamp:
- 08/05/08 12:15:33 (5 months ago)
- Files:
-
- django/branches/gis (modified) (1 prop)
- django/branches/gis/django/core/management/commands/compilemessages.py (modified) (1 diff)
- django/branches/gis/django/core/management/commands/test.py (modified) (1 diff)
- django/branches/gis/django/core/management/commands/testserver.py (modified) (1 diff)
- django/branches/gis/django/core/management/sql.py (modified) (3 diffs)
- django/branches/gis/django/core/management/validation.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis
- Property svnmerge-integrated changed from /django/trunk:1-7978 to /django/trunk:1-8214
django/branches/gis/django/core/management/commands/compilemessages.py
r7918 r8215 2 2 import sys 3 3 from optparse import make_option 4 from django.core.management.base import BaseCommand 5 from django.core.management.color import no_style 4 from django.core.management.base import BaseCommand, CommandError 6 5 7 6 try: django/branches/gis/django/core/management/commands/test.py
r7354 r8215 18 18 def handle(self, *test_labels, **options): 19 19 from django.conf import settings 20 from django.db.models import get_app, get_apps21 20 22 21 verbosity = int(options.get('verbosity', 1)) django/branches/gis/django/core/management/commands/testserver.py
r7354 r8215 18 18 19 19 def handle(self, *fixture_labels, **options): 20 from django.conf import settings21 20 from django.core.management import call_command 22 21 from django.test.utils import create_test_db django/branches/gis/django/core/management/sql.py
r7836 r8215 182 182 opts = model._meta 183 183 for f in opts.local_many_to_many: 184 if isinstance(f.rel, generic.GenericRel):184 if not f.creates_table: 185 185 continue 186 186 if cursor and table_name_converter(f.m2m_db_table()) in table_names: … … 354 354 inline_references = connection.features.inline_fk_references 355 355 for f in opts.local_many_to_many: 356 if not isinstance(f.rel, generic.GenericRel):356 if f.creates_table: 357 357 tablespace = f.db_tablespace or opts.db_tablespace 358 358 if tablespace and connection.features.supports_tablespaces: … … 436 436 437 437 # Post-creation SQL should come before any initial SQL data is loaded. 438 # However, this should not be done for fields that are part of a 439 # a parentmodel (via model inheritance).438 # However, this should not be done for fields that are part of a a parent 439 # model (via model inheritance). 440 440 nm = opts.init_name_map() 441 post_sql_fields = [f for f in opts. fields if nm[f.name][1] is None and hasattr(f, '_post_create_sql')]441 post_sql_fields = [f for f in opts.local_fields if hasattr(f, 'post_create_sql')] 442 442 for f in post_sql_fields: 443 output.extend(f. _post_create_sql(style, model._meta.db_table))443 output.extend(f.post_create_sql(style, model._meta.db_table)) 444 444 445 445 # Some backends can't execute more than one SQL statement at a time, django/branches/gis/django/core/management/validation.py
r7979 r8215 103 103 e.add(opts, "Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) 104 104 105 seen_intermediary_signatures = [] 105 106 for i, f in enumerate(opts.local_many_to_many): 106 107 # Check to see if the related m2m field will clash with any … … 113 114 if isinstance(f.rel.to, (str, unicode)): 114 115 continue 115 116 if getattr(f.rel, 'through', None) is not None: 117 if hasattr(f.rel, 'through_model'): 118 from_model, to_model = cls, f.rel.to 119 if from_model == to_model and f.rel.symmetrical: 120 e.add(opts, "Many-to-many fields with intermediate tables cannot be symmetrical.") 121 seen_from, seen_to, seen_self = False, False, 0 122 for inter_field in f.rel.through_model._meta.fields: 123 rel_to = getattr(inter_field.rel, 'to', None) 124 if from_model == to_model: # relation to self 125 if rel_to == from_model: 126 seen_self += 1 127 if seen_self > 2: 128 e.add(opts, "Intermediary model %s has more than two foreign keys to %s, which is ambiguous and is not permitted." % (f.rel.through_model._meta.object_name, from_model._meta.object_name)) 129 else: 130 if rel_to == from_model: 131 if seen_from: 132 e.add(opts, "Intermediary model %s has more than one foreign key to %s, which is ambiguous and is not permitted." % (f.rel.through_model._meta.object_name, rel_from._meta.object_name)) 133 else: 134 seen_from = True 135 elif rel_to == to_model: 136 if seen_to: 137 e.add(opts, "Intermediary model %s has more than one foreign key to %s, which is ambiguous and is not permitted." % (f.rel.through_model._meta.object_name, rel_to._meta.object_name)) 138 else: 139 seen_to = True 140 if f.rel.through_model not in models.get_models(): 141 e.add(opts, "'%s' specifies an m2m relation through model %s, which has not been installed." % (f.name, f.rel.through)) 142 signature = (f.rel.to, cls, f.rel.through_model) 143 if signature in seen_intermediary_signatures: 144 e.add(opts, "The model %s has two manually-defined m2m relations through the model %s, which is not permitted. Please consider using an extra field on your intermediary model instead." % (cls._meta.object_name, f.rel.through_model._meta.object_name)) 145 else: 146 seen_intermediary_signatures.append(signature) 147 seen_related_fk, seen_this_fk = False, False 148 for field in f.rel.through_model._meta.fields: 149 if field.rel: 150 if not seen_related_fk and field.rel.to == f.rel.to: 151 seen_related_fk = True 152 elif field.rel.to == cls: 153 seen_this_fk = True 154 if not seen_related_fk or not seen_this_fk: 155 e.add(opts, "'%s' has a manually-defined m2m relation through model %s, which does not have foreign keys to %s and %s" % (f.name, f.rel.through, f.rel.to._meta.object_name, cls._meta.object_name)) 156 else: 157 e.add(opts, "'%s' specifies an m2m relation through model %s, which has not been installed" % (f.name, f.rel.through)) 158 116 159 rel_opts = f.rel.to._meta 117 160 rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()
