I am writing my first django app. I have Items, which can have multiple 
comments associated with them.

Normally, I could express this in my model as:

---
class Comment(models.Model):
        comment = models.TextField(core=True)
        item = models.ForeignKey(Item)

class Item(models.Model):
        name = models.CharField(core=True, max_length=255, unique=True)
---

However, I am trying to learn to split my project up into individual 
applications, and have thus put the comment functionality in its own 
app. I dont mind if the Item app knows about the Comment app, but I 
don't want to Comment app to reference the Item app (so I can use 
comments with other apps / types in the future).

So, is there anyway to express a OneToMany relationship from the Item? 
Something like:

class Comment(models.Model):
        comment = models.TextField(core=True)
        

class Item(models.Model):
        name = models.CharField(core=True, max_length=255, unique=True)
        comments = models.OneToMany(Comment)

That would accomplish the same as above, but would allow me to keep my 
Comment model from having to know what type of objects it is being 
associated with.

I apologize if this has an obvious answer. Again, I am new to django, 
and trying to work my way through the best way to use the framework 
(which I love, btw).

mike chambers

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to