#26023: Importing GenericForeignKey on Django 1.9
-------------------------------------+-------------------------------------
     Reporter:  Chris7               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:                       |                  Version:  1.9
  contrib.contenttypes               |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  generic foreign      |             Triage Stage:
  keys                               |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Chris7):

 An additional error arises for that case:


 {{{
 >>> from django.conf import settings
 >>> settings.configure()
 >>> import django
 >>> django.setup()
 >>> from django.contrib.contenttypes.fields import GenericForeignKey
 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 103, in __new__
     "application was loaded. " % (module, name))
 RuntimeError: Model class django.contrib.contenttypes.models.ContentType
 doesn't declare an explicit app_label and either isn't in an application
 in INSTALLED_APPS or else was imported before its application was loaded
 }}}

 I understand this isn't a normal situation. But should importing the GFK
 field really cause the application loading logic to execute?

--
Ticket URL: <https://code.djangoproject.com/ticket/26023#comment:6>
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/064.bfd052a12225d8b19d067af0e7b8fff2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to