You can define a function that returns the path to upload the image, in
this function you receive as argument the object being saved (instance) and
the name of the file (filename). You can return whatever you want as a path
(that include the filename)
def upload_path(instance, filename):
retur
This is the same as the FileField. The UploadedFile class has a name
property, which can be used..
https://docs.djangoproject.com/en/dev/topics/http/file-uploads/#handling-uploaded-files
On Jan 19, 9:56 am, Mike Dewhirst wrote:
> How do I get the actual filename of the uploaded image?
>
> The
How do I get the actual filename of the uploaded image?
The docs mention ...
FileField.upload_to
A local filesystem path that will be appended to your MEDIA_ROOT setting
to determine the value of the url attribute.
... and presumably the widget which uploads the image knows the filename
to t
2009/7/5 Mirat Can Bayrak :
> I have another question. You are naming images as hash of random number.
> There is a small chance to produce same name i think. It is not good way to
> give name ha?
The slug field has a unique=True argument, so if the same file name
does happen to be produced, it
I have another question. You are naming images as hash of random number. There
is a small chance to produce same name i think. It is not good way to give name
ha?
--
Mirat Can Bayrak
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
On Jul 2, 12:29 pm, Andrew Turner wrote:
> Talking to myself again, I've changed the save method slightly:-
>
> def save(self):
> if not self.slug:
> name = hashlib.sha1(str(random.random())).hexdigest()[:16]
> self._my_filename = '%s.jpg' % (name)
>
2009/7/2 Andrew Turner :
> 2009/7/2 Andrew Turner :
>> Would it be possible to define the hashed filename in the save method,
>> and then pass it to the upload_to argument of the ImageField?
>
> In answer to my own question, this seems to work:-
>
> def get_path(instance, name):
> return instanc
2009/7/2 Andrew Turner :
> Would it be possible to define the hashed filename in the save method,
> and then pass it to the upload_to argument of the ImageField?
In answer to my own question, this seems to work:-
def get_path(instance, name):
return instance._my_filename
class Photo(models.M
2009/7/1 Rajesh D :
> Judging by the discussions on the above mentioned ticket, it may be a
> while before this behaviour is reverted back (if it is reverted back
> at all.)
I'm not seeking to have the new behaviour reversed - if the powers
that be say the new way is more robust, I'm happy to go
>
> > This is an issue which, I believe, is related to Ticket #10788
> > (http://code.djangoproject.com/ticket/10788).
>
> > The following code snippet used to work with Django 1.0.2, but with
> > the latest svn version the slug is not being set to the filename
> > produced by get_path because, as
2009/6/30 Andrew Turner :
> Hi,
>
> This is an issue which, I believe, is related to Ticket #10788
> (http://code.djangoproject.com/ticket/10788).
>
> The following code snippet used to work with Django 1.0.2, but with
> the latest svn version the slug is not being set to the filename
> produced b
Hi,
This is an issue which, I believe, is related to Ticket #10788
(http://code.djangoproject.com/ticket/10788).
The following code snippet used to work with Django 1.0.2, but with
the latest svn version the slug is not being set to the filename
produced by get_path because, as I understand it,
12 matches
Mail list logo