django model problem
Mark
ma.ston.99 at hotmail.com
Fri Apr 3 11:58:16 EDT 2009
Hi,
Say I have these simple models:
class Musician(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
class Album(models.Model):
artist = models.ForeignKey(Musician)
name = models.CharField(max_length=100)
Now in `Musician` I want to add a field "last_album".
How can I do that? I'd like to be able to write:
m = Musician(pk=1)
print m.last_album.name
When I try:
last_album = models.OneToOneField(Album)
it somehow works but creates a (useless) unique index for last_album.
And I don't need additional related field in the Album model (it's also
created now).
Thanks,
MS
More information about the Python-list
mailing list