John,

If you don't have to fill any of Checkbox's fields (attended,
was_drunk, silly_walk, naughty or been_seen), then i don't think you
have to create an instance of it bounded with an Event. Create it when
you have one of these fields. This way if you want to get a real
statistic of how many Checkboxes exist, for example, it will be much
more easier.
What do you think?

[]s
Diego Ucha

On Apr 25, 7:27 pm, jrmorrisnc <[EMAIL PROTECTED]> wrote:
> So, I have it doing what I want now:
>
> <snip>
>  class Event(models.Model):
>         date = models.DateTimeField()
>         description = models.TextField()
>
>         def __init__(self, *args, **kwargs):
>                 models.Model.__init__(self, *args, **kwargs)
>                 self.checklist = CheckList(self.id)
>                 self.checklist.save()
>
>         def __str__(self):
>                 return self.date
>
>         class Admin:pass
>
> class CheckList(models.Model):
>        event = models.OneToOneField(Event)
>        attended = models.BooleanField()
>        was_drunk = models.BooleanField()
>        silly_walk = models.BooleanField()
>        naughty = models.BooleanField()
>        been_seen = models.BooleanField()
>
>        def __str__(self):
>                 return 'Event checklist for ' + self.event.name
>
> </snip>
>
> When I create an Event, it creates related instance of CheckList and
> should share the same pk, which is currently how one-to-ones are
> handled in Django.
> If/when that changes I will have to either shift to managing one set
> of pk's myself, or both, or adapt (potentially) to the new way, I
> think.
>
> Anyone have any thoughts or suggestions? Is this likely to blow up, or
> a generally bad way of doing things? I was trying to assert that for
> each instance of Event there must be a corresponding instance of
> CheckList at the lowest level possible, make it part of the init of
> the object in question.
>
> Thanks!
>
> On Apr 24, 8:02 pm, jrmorrisnc <[EMAIL PROTECTED]> wrote:
>
> > So, after re-reading the related_name / related_objects documentation
> > I've dealt with my lack of understand on properly getting __str__
> > method to return what I want, I thnk.
>
> > And the other part, creating an instance of CheckList whenever an
> > Event is created should be easy, too.
>
> > Just wasn't looking at the first part in the right way.
--~--~---------~--~----~------------~-------~--~----~
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