1
0
mirror of https://github.com/django/django.git synced 2025-06-05 03:29:12 +00:00

magic-removal: Changed model validator not to check for 'singular' on ManyToManyFields, because that's not going to be used anymore.

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2243 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-02-03 20:01:58 +00:00
parent ce0c6887d6
commit b9c2b3e83f

View File

@ -1,7 +1,7 @@
# Django management-related functions, including "CREATE TABLE" generation and # Django management-related functions, including "CREATE TABLE" generation and
# development-server initialization. # development-server initialization.
import django import django
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
import os, re, sys, textwrap import os, re, sys, textwrap
from optparse import OptionParser from optparse import OptionParser
@ -810,7 +810,7 @@ def get_validation_errors(outfile):
"Validates all installed models. Writes errors, if any, to outfile. Returns number of errors." "Validates all installed models. Writes errors, if any, to outfile. Returns number of errors."
from django.db import models from django.db import models
from django.db.models.fields.related import RelatedObject from django.db.models.fields.related import RelatedObject
e = ModelErrorCollection(outfile) e = ModelErrorCollection(outfile)
for cls in models.get_models(): for cls in models.get_models():
opts = cls._meta opts = cls._meta
@ -860,14 +860,8 @@ def get_validation_errors(outfile):
e.add(opts, "'%s.%s' related field: Clashes with related m2m field '%s.%s'" % (opts.object_name, f.name, rel_opts.object_name, rel_name)) e.add(opts, "'%s.%s' related field: Clashes with related m2m field '%s.%s'" % (opts.object_name, f.name, rel_opts.object_name, rel_name))
elif rel_name in [r.OLD_get_accessor_name() for r in rel_opts.get_all_related_objects() if r.field is not f]: elif rel_name in [r.OLD_get_accessor_name() for r in rel_opts.get_all_related_objects() if r.field is not f]:
e.add(opts, "'%s.%s' related field: Clashes with related field on '%s.%s'" % (opts.object_name, f.name, rel_opts.object_name, rel_name)) e.add(opts, "'%s.%s' related field: Clashes with related field on '%s.%s'" % (opts.object_name, f.name, rel_opts.object_name, rel_name))
# Check for multiple ManyToManyFields to the same object, and
# verify "singular" is set in that case.
for i, f in enumerate(opts.many_to_many):
for previous_f in opts.many_to_many[:i]:
if f.rel.to._meta == previous_f.rel.to._meta and f.rel.singular == previous_f.rel.singular:
e.add(opts, 'The "%s" field requires a "singular" parameter, because the %s model has more than one ManyToManyField to the same model (%s).' % (f.name, opts.object_name, previous_f.rel.to._meta.object_name))
for i, f in enumerate(opts.many_to_many):
# Check to see if the related m2m field will clash with any # Check to see if the related m2m field will clash with any
# existing fields, m2m fields, m2m related objects or related objects # existing fields, m2m fields, m2m related objects or related objects
if f.rel: if f.rel:
@ -1060,11 +1054,11 @@ DEFAULT_ACTION_MAPPING = {
} }
NO_SQL_TRANSACTION = ( NO_SQL_TRANSACTION = (
'adminindex', 'adminindex',
'createcachetable', 'createcachetable',
'dbcheck', 'dbcheck',
'install', 'install',
'installperms', 'installperms',
'reset', 'reset',
'sqlindexes' 'sqlindexes'
) )