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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---