How can a class hold an array of classes in django
<p>I have been having trouble using django. Right now, I have a messagebox class that is suppose to hold messages, and a message class that extends it. How do I make it so messagebox will hold messages?</p>

<p>Something else that I cannot figure out is how classes are to interact. Like, I have a user that can send messages. Should I call its method to call a method in messagebox to send a msg or can I have a method in user to make a msg directly. </p>

<p>My teacher tries to accentuate cohesion and coupling, but he never even talks about how to implement this in django or implement django period. Any help would be appreciated.</p>

<p>You're confusing two different things here. A class can easily have an attribute that is a list which contains instances of another class, there is nothing difficult about that. </p>

<p>(But note that there is no way in which a Message should extend MessageBox; this should be composition, not inheritance.)</p>

<p>However then you go on to talk about Django models. But Django models, although they are Python classes, also represent tables in the database. And the way you represent one table containing a list of entries in another table is via a foreign key field. So in this case your Message model would have a ForeignKey to MessageBox.</p>

<p>Where you put the send method depends entirely on your logic. A message should probably know how to send itself, so it sounds like the method would go there.</p>

python django