for this problem i used the Generic foreign
key/relationships. an
example in the documentation:
http://www.djangoproject.com/documentation/m
odels/generic_relations/
although i didn't find anything about it in the Model API.
there is another thing i'd like to do with the above
comments example:
what if for video and user comments there is an extra field
char field.
and this char field need different choices (i.e.
choices=VIDEO_COMMENT_CHOICES) for video and user comments.
is there a
way to fit this in the generic relation way? the way i'd
think it would
work is:
class Comment:
CHOICES = ()
comment = models.TextField()
choice = models.charField(choices=CHOICES)
class VideoComment(models.Model, Comment):
CHOICES = (('a', 'Apple'), ('p', 'Pear'))
video = models.ForeignKey(Video)
class UserComment(models.Model, Comment):
CHOICES = (('a', 'Admin'), ('p', 'Public User'))
user = models.ForeignKey(User)
the CHOICES in VideoComment would then be used instead of
the blank on
in Comment. (i'm new to python so don't know if this is
actually
viable)
--~--~---------~--~----~------------~-------~--~----~
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
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|