Count the number of drawings each artist has?
Hello,
In my model I have artists and drawings. Each drawing has a ForeignKey(Artist)
I'm trying to count the number of drawings each artist has, but I don't know how to do it...
Below a simplified version of my code.
class Artist(models.Model):
name = models.CharField(max_length=140)
def number_of_drawing(self):
return drawing.count() # how to do this ?
class Drawing(models.Model):
artist = models.ForeignKey(Artist)
description = models.TextField()
Can you help me write the number_of_drawing function?
Thanks!
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home