Re: Accessing model instance on pre_save signal

2009-11-25 Thread neridaj
Thanks Tim. That's funny you just posted that because I just got done doing that and was going to post it as solved. Cheers, J On Nov 25, 1:48 pm, Tim Valenta wrote: > I know how messed up this all seems, so I sympathize.  I totally want > to store items according

Re: Accessing model instance on pre_save signal

2009-11-25 Thread Tim Valenta
I know how messed up this all seems, so I sympathize. I totally want to store items according to a related object's name or id or whatever. However, I'm using upload_to in a more straightforward manner, and it seems to work out alright. Tell me if you've already tried it this way: class

Re: Accessing model instance on pre_save signal

2009-11-25 Thread neridaj
I'm trying to access the current instance of ScreenShot related to the current instance of WebProject, in order to get the slug field of WebProject to use as a upload directory but I don't think I can because there's no primary key in the db yet. I need to call change_upload_to when the instance

Re: Accessing model instance on pre_save signal

2009-11-25 Thread Preston Holmes
I'm a bit confused on a few points here. The upload_to field attribute should be atomic to the imagefield - it doesn't rely on related models. your change_upload_to creates a new screenshot - but doesn't connect it to the current WebProject instance. Is that what you are trying to do? s =

Re: Accessing model instance on pre_save signal

2009-11-24 Thread Tim Valenta
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

Accessing model instance on pre_save signal

2009-11-24 Thread neridaj
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