summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2011-07-14 00:27:55 +0000
committerRamiro Morales <cramm0@gmail.com>2011-07-14 00:27:55 +0000
commita925b3780e09986131059b7a12f78e968267e0fa (patch)
tree1a4c47bb88ce499bcdce6d78ec3ff89d8bf1ee36
parent220ce42333b8bff16b4b0b434cfc2570dcce9985 (diff)
downloaddjango-a925b3780e09986131059b7a12f78e968267e0fa.tar.gz
[1.3.X] Reverted [14563] because it introduced a dependency from core on a contrib app (contenttypes). Fixes #16283, Refs #3055. Thanks TheRoSS for the report and Aymeric Augustin for finding the problem.
This caused models shipped with some contrib apps to pollute the namespace when user's apps had the same name (e.g. auth, sites), even when these contrib apps weren't installed. This undesired loading of contrib apps happened when model validation was executed, for example when running management commands that set or inherit `requires_model_validation=True`: cleanup, dumpdata, flush, loaddata, reset, runfcgi, sql, sqlall, sqlclear, sqlcustom, sqlflush, sqlindexes, sqlinitialdata, sqlreset, sqlsequencereset, syncdb, createsuperusers, ping_google, collectstatic, findstatic. This could also cause hard to diagnose problems e.g. when performing reverse URL resolving. Backport of [16493] from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16541 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/validation.py7
-rw-r--r--tests/modeltests/invalid_models/models.py17
2 files changed, 0 insertions, 24 deletions
diff --git a/django/core/management/validation.py b/django/core/management/validation.py
index 2eb6340de9..6fdbfca0f0 100644
--- a/django/core/management/validation.py
+++ b/django/core/management/validation.py
@@ -1,6 +1,5 @@
import sys
-from django.contrib.contenttypes.generic import GenericForeignKey, GenericRelation
from django.core.management.color import color_style
from django.utils.itercompat import is_iterable
@@ -240,12 +239,6 @@ def get_validation_errors(outfile, app=None):
e.add(opts, "'%s' specifies an m2m relation through model %s, "
"which has not been installed" % (f.name, f.rel.through)
)
- elif isinstance(f, GenericRelation):
- if not any([isinstance(vfield, GenericForeignKey) for vfield in f.rel.to._meta.virtual_fields]):
- e.add(opts, "Model '%s' must have a GenericForeignKey in "
- "order to create a GenericRelation that points to it."
- % f.rel.to.__name__
- )
rel_opts = f.rel.to._meta
rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()
diff --git a/tests/modeltests/invalid_models/models.py b/tests/modeltests/invalid_models/models.py
index ab9edd6461..45f302413d 100644
--- a/tests/modeltests/invalid_models/models.py
+++ b/tests/modeltests/invalid_models/models.py
@@ -4,7 +4,6 @@
This example exists purely to point out errors in models.
"""
-from django.contrib.contenttypes import generic
from django.db import models
class FieldErrors(models.Model):
@@ -219,21 +218,6 @@ class InvalidSetNull(models.Model):
class InvalidSetDefault(models.Model):
fk = models.ForeignKey('self', on_delete=models.SET_DEFAULT)
-class Tag(models.Model):
- name = models.CharField("name", max_length=20)
-
-class TaggedObject(models.Model):
- object_id = models.PositiveIntegerField("Object ID")
- tag = models.ForeignKey(Tag)
- content_object = generic.GenericForeignKey()
-
-class UserTaggedObject(models.Model):
- object_tag = models.ForeignKey(TaggedObject)
-
-class ArticleAttachment(models.Model):
- tags = generic.GenericRelation(TaggedObject)
- user_tags = generic.GenericRelation(UserTaggedObject)
-
model_errors = """invalid_models.fielderrors: "charfield": CharFields require a "max_length" attribute that is a positive integer.
invalid_models.fielderrors: "charfield2": CharFields require a "max_length" attribute that is a positive integer.
invalid_models.fielderrors: "charfield3": CharFields require a "max_length" attribute that is a positive integer.
@@ -343,5 +327,4 @@ invalid_models.nonuniquefktarget2: Field 'bad' under model 'FKTarget' must have
invalid_models.nonexistingorderingwithsingleunderscore: "ordering" refers to "does_not_exist", a field that doesn't exist.
invalid_models.invalidsetnull: 'fk' specifies on_delete=SET_NULL, but cannot be null.
invalid_models.invalidsetdefault: 'fk' specifies on_delete=SET_DEFAULT, but has no default value.
-invalid_models.articleattachment: Model 'UserTaggedObject' must have a GenericForeignKey in order to create a GenericRelation that points to it.
"""