Re: Model Relationship Causing Error
On Sun, 2009-03-22 at 22:17 -0700, Super McFly wrote: [...] > Of course I was just doing something silly. I was using > 'myproject.media.models.Image' when I only needed 'media.Image'. It's > still not clear to me why this format is used but it works. That's what this bit of the documentation means: "To refer to models defined in another application, you must instead explicitly specify the application label." Django refers to a lot of model information using . format, which looks a bit confusing if you're not paying attention, because it looks like a Python import path. Not the decision I would have made, but it's not too hard to get used to and it's too late to change now. One of those things that are clearer with hindsight. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model Relationship Causing Error
> The solutions isn't too hard, though. Use the "string format" for > referencing from, say, Image -> Container. > Seehttp://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkeyfor > documentation about this. Thank you for replying. I tried that method before but I received an error saying it " has either not been installed or is abstract". Of course I was just doing something silly. I was using 'myproject.media.models.Image' when I only needed 'media.Image'. It's still not clear to me why this format is used but it works. I actually ran into this problem sometime last year and it caused me to give up. But now I'm back, and hopefully I'll be the one giving advice next time. Thanks again, Martin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model Relationship Causing Error
On Sun, 2009-03-22 at 14:37 -0700, Super McFly wrote: > This is a bit of a tricky one but I need help solving the following > error: > > ImportError: cannot import name Container > > I'm sure it has something to do with the unusual relationships I have > between two models. I'll put a simplified version below. You've got a circlar import going on. The containers/models.py file needs to import the "Image" name from media/models.py, but in the course of importing that latter file, it needs to import the "Container" name from containers/models.py. However, containers/models.py hasn't been imported properly yet by this point, so hilarity results. The solutions isn't too hard, though. Use the "string format" for referencing from, say, Image -> Container. See http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey for documentation about this. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---