Browse files

Reverted [14563] because it introduced a dependency from core on a co…

…ntrib 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.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
ramiro committed Jul 3, 2011
1 parent d138906 commit 1d270ac8a34b9a1f562d2e46411121499caa6e41
Showing with 0 additions and 24 deletions.
  1. +0 −7 django/core/management/
  2. +0 −17 tests/modeltests/invalid_models/
@@ -1,6 +1,5 @@
import sys
-from django.contrib.contenttypes.generic import GenericForeignKey, GenericRelation
from import color_style
from django.utils.itercompat import is_iterable
@@ -235,12 +234,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.rel.through)
- elif isinstance(f, GenericRelation):
- if not any([isinstance(vfield, GenericForeignKey) for vfield in]):
- e.add(opts, "Model '%s' must have a GenericForeignKey in "
- "order to create a GenericRelation that points to it."
- %
- )
rel_opts =
rel_name = RelatedObject(, cls, f).get_accessor_name()
@@ -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 @@ class ArticleAttachment(models.Model):
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.

0 comments on commit 1d270ac

Please sign in to comment.