On Fri, Mar 27, 2009 at 9:25 AM, Robert Chan <robc...@gmail.com> wrote:
> > Hey is this possible? > > I'm getting angry 500s back > > class TeamBulletin(models.Model): > team = models.ForeignKey(Team) > author = models.ForeignKey(User) > title = models.CharField(max_length = 500, blank = False) > body = models.TextField(blank = False) > image = models.ImageField(upload_to='images/team/%s/bulletins/' % > self.team.id,blank = True) > editdate = models.DateTimeField(null = True) > createdate = models.DateTimeField(blank = False) > def __str__(self): > return self.team.name > > > It's particularly angry at the image field portion. I'm trying to get > it so that these images are organized under their own teams > respectively, but I have no way of access the team.id from within the > class. > Or is this a value I have to pull using a function? > Yes, you need a function (callable). If you want your upload_to value to be dependent on a value from the instance of the model involved, then you need to specify a callable for that, as described here: http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield Karen --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---