Re: foreign key id as part of models.FileField(upload_to=...)

2009-03-14 Thread Christoph Wegscheider
On 14 Mrz., 22:42, Dirk Eschler wrote: > Am Samstag 14 März 2009 22:29:16 schrieb Dirk Eschler: > > > def get_img_storage_path(instance, filename): > >     return '%salbums/images/%s/' % (settings.MEDIA_ROOT, instance.album.pk) > > Forgot the filename in my example... > > def get_img_storage_pa

foreign key id as part of models.FileField(upload_to=...)

2009-03-14 Thread Christoph Wegscheider
Hi, I want to upload photos to directories structured by the album primary key. I have the following model: class Photo(models.Model): album = models.ForeignKey(Album) img = models.FileField(upload_to='albums/images/' + str(album.pk) + '/', blank=True) The str(album.pk) part is not work

Re: Foreign Key query question

2009-03-08 Thread Christoph Wegscheider
On 8 Mrz., 18:54, Daniel Roseman wrote: > On Mar 8, 3:50 pm, Christoph Wegscheider > > > > wrote: > > Hi, > > I have the following model: > > class Message(models.Model): > >     student = models.ForeignKey(Student,  blank=True,  null=True) > >

Foreign Key query question

2009-03-08 Thread Christoph Wegscheider
Hi, I have the following model: class Message(models.Model): student = models.ForeignKey(Student, blank=True, null=True) message = models.CharField(max_length=200) I want to filter for: message_list = Message.objects.filter(student=1) OR message_list = Message.objects.filter(student=Non