Hi,

I have a method in a class that filters related objects  
(get_representative_recording):

class Song(models.Model):
     title                   = models.CharField(max_length=50)
     description             = models.TextField(blank=True)

     def get_representative_recording(self):
         # There is always only one representative_recording, so I'm  
using get()
         representative_recording =  
self.recording_set.get(represents_song=True)
         return representative_recording

class Recording(models.Model):
     song                    = models.ForeignKey(Song)
     mp3                     = models.FileField(upload_to='songs')
     description             = models.TextField(blank=True)
     represents_song         = models.BooleanField()

The method defines "row-level"-functionality for songs, but that's  
"table-wide" functionality for recordings...
See here: http://www.djangoproject.com/documentation/model-api/#model-methods

So should this stay a method or be transfered into a custom manager?
What would be preferable and why?

I have no idea how I could transfer the functionality into a manager  
anyway...
Someone knows how to do that?

I thought about somehow overriding recording_set...

-benjamin




--~--~---------~--~----~------------~-------~--~----~
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