﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26023	Importing GenericForeignKey on Django 1.9	Chris Mitchell	nobody	"It appears it is not possible to import GenericForeignKey from outside a live Django project in 1.9.  To reproduce this error:


{{{
from django.conf import settings
settings.configure()
from django.contrib.contenttypes.fields import GenericForeignKey
}}}

Produces:

{{{
Traceback (most recent call last):
  File ""<stdin>"", line 1, in <module>
  File ""/home/chris/.virtualenvs/wooey/local/lib/python2.7/site-packages/django/contrib/contenttypes/fields.py"", line 5, in <module>
    from django.contrib.contenttypes.models import ContentType
  File ""/home/chris/.virtualenvs/wooey/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py"", line 159, in <module>
    class ContentType(models.Model):
  File ""/home/chris/.virtualenvs/wooey/local/lib/python2.7/site-packages/django/db/models/base.py"", line 94, in __new__
    app_config = apps.get_containing_app_config(module)
  File ""/home/chris/.virtualenvs/wooey/local/lib/python2.7/site-packages/django/apps/registry.py"", line 239, in get_containing_app_config
    self.check_apps_ready()
  File ""/home/chris/.virtualenvs/wooey/local/lib/python2.7/site-packages/django/apps/registry.py"", line 124, in check_apps_ready
    raise AppRegistryNotReady(""Apps aren't loaded yet."")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
}}}

This seems to be occurring because ModelBase is attempting to get the app config, but the configuration step has not occurred. "	Bug	closed	contrib.contenttypes	1.9	Normal	invalid	generic foreign keys		Unreviewed	0	0	0	0	0	0
