On 9/7/06, Jay Parlar <[EMAIL PROTECTED]> wrote:

The only reason I can guess is that because the two models are defined
in separate applications.

Am I missing something here?

I just tried the following in a test project;

testproject/mytest/models.py:------------
from django.db import models

class Image(models.Model):
    name = models.CharField(maxlength=20)
testproject/mytest2/models.py-----------
from django.db import models
from testproject.mytest.models import Image

class Article(models.Model):
    name = models.CharField (maxlength=20)
    img = models.ForeignKey(Image)

---

Then, add both apps to INSTALLED_APPS, sync, and in a shell:

>from testproject.mytest.models import Image
>from testproject.mytest2.models import Article

>img1 = Image(name='foo')
>img1.save()

>art1 = Article(name='bar', img=img1)
>art1.save()

>img1 = Image.objects.all()[0]
>print img1.article_set.all()

returns [<Article: Article object>] as expected. Do you get the same result if you use this project?

Can you provide any more details about you application?

The only reason I can think that you wouldn't get a _set descriptor is in the case of a m2m relation to self.

PS. An interesting (and perhaps related) sidenote: In my
INSTALLED_APPS, I *have* to have the 'stockphoto' app appear before
the 'articles' app, otherwise I get the following when trying to
import 'Article' in IPython:

ImportError: No module named model

This is an reference resolution problem; Article references Photo, so Photo needs to be defined first.

Yours,
Russ Magee %-)


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to