I think the answer is just in the documentation on the method: http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.pre_save
No worries though. Signals are such a strangely uncovered topic in the main tutorials, and aren't easy to find documentation for unless you know what you're after. It'll be in kwargs['instance'] Tim On Nov 24, 6:52 pm, neridaj <neri...@gmail.com> wrote: > Hello, > > I'm trying to change the upload_to attribute of an ImageField so that > it is in the format "web_projects/year/slug/". The problem I am having > is that the ForeignKey model is getting saved before the related > ScreenShot model is able to call it's save method to change upload_to. > I'm trying to use a pre_save signal to reverse the order of saving but > I'm not sure how to access the current instance of the ScreenShot > model to call it's save method. Thanks for any suggestions. > > class ScreenShot(models.Model): > project = models.ForeignKey(WebProject) > image = models.ImageField(upload_to="web_projects/%Y/") > page_title = models.CharField(max_length=250, help_text="Maximum 250 > characters.") > > def __unicode__(self): > return self.page_title > > def save(self): > self.image.upload_to="web_projects/%Y/"+self.project.slug > super(ScreenShot, self).save() > > def change_upload_to(sender, **kwargs): > s = ScreenShot() # not sure how to access current instance > s.save() > > pre_save.connect(change_upload_to, sender=WebProject) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.