> I'd like to save the image file into a folder based on the ID of the
> new instance.
I wouldn't actually recommend saving your file with the filename being the
primary key of your model anyway. It makes it a pain if you do database dumps
or loads and need to keep the primary key in sync with y
that only seems to work on ModelForm, not Model. Or did i miss
something? That functionality seems to be what i'm after though :)
On Jul 8, 4:07 pm, Kenneth Gonsalves wrote:
> On Friday 09 July 2010 03:16:28 TheIvIaxx wrote:
>
> > I'd like to save the image file into a folder based on the ID of
On Friday 09 July 2010 03:16:28 TheIvIaxx wrote:
> I'd like to save the image file into a folder based on the ID of the
> new instance. The only thing i can think of is to create the new
> folder mid transaction. I guess another way to do it would be to save
> a new instance with a temp file or s
Lets say for a model i have the following:
class Image(models.Model):
image = models.ImageField()
>>> image = Image()
>>> # Somehow get ID
>>> destination = open('ID/name.jpg', 'wb+')
>>> for chunk in f.chunks():
...destination.write(chunk)
>>> destination.close()
>>> image.image = "I
Did you really mean for commit=FALSE or pre_save signal???
Praveen
On May 29, 5:22 pm, Euan Goddard
wrote:
> Hi,
>
> Could you explain the situation in a little more detail as I don't
> quite follow what you mean. As far as I'm aware if you have something
> like the following:
>
> >>> my_inst = M
Hi,
Could you explain the situation in a little more detail as I don't
quite follow what you mean. As far as I'm aware if you have something
like the following:
>>> my_inst = MyModel(foo="bar", ...)
>>> my_inst.save()
You'll have the pk at this point even if the transaction hasn't been
committed
Hello, I am trying to figure out how to get a pk in the middle of a
transaction. I need to set a field in the model based on the
ID(default pk) to be given. As far as a i know, this ID should be
allocated during the transaction. So i would imagine it would do the
INSERT, then i could get the pk a
7 matches
Mail list logo