#26023: Importing GenericForeignKey on Django 1.9
--------------------------------------+----------------------------------
Reporter: Chris7 | Owner: nobody
Type: Bug | Status: new
Component: contrib.contenttypes | Version: 1.9
Severity: Normal | Keywords: generic foreign keys
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+----------------------------------
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.
}}}
My guess is contenttypes is attempting to build the list of models, but
failing because there is no app to initialize.
--
Ticket URL: <https://code.djangoproject.com/ticket/26023>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.1dfa8f25774bb67125d20b5b6442ab51%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.