#16511: Problem with import and GFK -------------------------------------+------------------------------------- Reporter: rjdg@… | Owner: nobody Type: Bug | Status: new Milestone: | Component: Version: 1.3 | contrib.contenttypes Keywords: | Severity: Normal import,genericforeignkey,genericrelation| Triage Stage: Unreviewed Has patch: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- Hello,
I have an error "Cannot import name <model name>" and find out why. It seems a bit strange so I report it as a bug. Description: We have two apps: x and y. And two Models: A (in x) and B (in y) B has a generic foreign key A has generic relation to B I added this line to y.models: from x.models import A And Django raises error: "Cannot import name A" when I try to use python manage.py commands. I needed this import line because I wanted to add third model - C in y.models, which would have a foreignkey to A I've tested it also in a new empty django project and it works (hmm, in fact doesn't work) exactly that way. Source: x.models: from django.db import models from django.contrib.contenttypes import generic from y.models import B class A: b_rel = generic.GenericRelation(B) y.models: from django.db import models from django.contrib.contenttypes import generic from x.models import A class B: content_object = generic.GenericForeignKey() class C: a = models.ForeignKey(A) Removing import of A (and respectivly, the foreignkey to A in C) fixes the problem. I think it shouldn't be like that. I don't want to split application y to store C in separate file. If it's a known problem I'm sorry, I've searched. -- Ticket URL: <https://code.djangoproject.com/ticket/16511> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.