Neither seem right to me. I'm not quite sure what the application
does, but it seems likely that a person only belongs to one family, in
which case you'll need a foreign key like this.

class Adult(models.Model):
    name = models.CharField(maxlength=30)
    partner = models.CharField(maxlength=30)
    kriskindle = models.CharField(maxlength=30)
    email = models.EmailField()
    family = models.ForeignKey(Family)

also the Kinder and the adult classes are similar, so you might like
to look at using inheritance, perhaps from a person class that looks
like

class Person(models.Model):
    name = models.CharField(maxlength=30)
    kriskindle = models.CharField(maxlength=30)
    family = models.ForeignKey(Family)

On Oct 23, 11:39 am, dustpuppy <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm starting off with Django and trying my first (toy) project. It's a
> Kris Kindle application (called "Secret Santa"? by some). Not exactly
> earth-shattering, but I want to start with something small.
>
> I'm unsure what approach to use when designing my model.
>
> The entities I am dealing with are Family, Adult and Kinder.
>
> Normally for a standalone application (using Java or Python), I would
> design a class Family, with fields/attributes representing arrays/
> lists of objects of the classes Adult and Kinder.
> (Apologies if my OOP terminology is mixed-up - I'm originally a C/Perl
> programmer!)
>
> I've started my Django design that way:
>
> class Adult(models.Model):
>     name = models.CharField(maxlength=30)
>     partner = models.CharField(maxlength=30)
>     kriskindle = models.CharField(maxlength=30)
>     email = models.EmailField()
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'partner', 'email')
>         pass
>
> class Kinder(models.Model):
>     name = models.CharField(maxlength=30)
>     excluded = models.ManyToManyField(Adult)
>     kriskindle = models.CharField(maxlength=30)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'excluded')
>         pass
>
> class Family(models.Model):
>     name = models.CharField(maxlength=30)
>     children = models.ManyToManyField(Kinder)
>     adults = models.ManyToManyField(Adult)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         pass
>
> On the other hand, for any previous Web development I've done (with
> PHP or Perl), I would have define just 2 entities, Adult and Kinder,
> and simply included family as a string attribute of each.
>
> class Adult(models.Model):
>     name = models.CharField(maxlength=30)
>     partner = models.CharField(maxlength=30)
>     kriskindle = models.CharField(maxlength=30)
>     email = models.EmailField()
>     family = models.CharField(maxlength=30)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'partner', 'email')
>         pass
>
> class Kinder(models.Model):
>     name = models.CharField(maxlength=30)
>     excluded = models.ManyToManyField(Adult)
>     kriskindle = models.CharField(maxlength=30)
>     family = models.CharField(maxlength=30)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'excluded')
>         pass
>
> I actually think the former would be easier to program, e.g. in terms
> of getting access to the lists of adults directly from the database,
> instead of having to retrieve it from a Family object first.
>
> Which of these would be the more appropriate way to do it in Django?
>
> Thanks in advance for taking the time to respond.
>
> Kind regards,
> Cormac.
--~--~---------~--~----~------------~-------~--~----~
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