For Chinese programmers,it's money
Tanjina Sharmin 于2021年9月3日周五 下午8:25写道:
> def path_and_renamecsv(instance, filename):
> upload_to = 'attendancesheet'
> ext = filename.split('.')[-1]
> # get filename
> if instance.pk:
> filename = '{}.{}'.format(instance.pk, ext)
> else:
> # set filename as
So right here what does the filename changes to?
On Fri, Sep 3, 2021, 1:25 PM Tanjina Sharmin
wrote:
> def path_and_renamecsv(instance, filename):
> upload_to = 'attendancesheet'
> ext = filename.split('.')[-1]
> # get filename
> if instance.pk:
> filename = '{}.{}'.format(instance.pk, ext)
>
Not sure what you mean by "work of", but Python is a dynamically typed
language so you can really pass whatever type you want to the function.
This line:
> ext = filename.split('.')[-1]
looks like the filename parameter is most likely expected to be a string
and this line:
> if instance.pk:
def path_and_renamecsv(instance, filename):
upload_to = 'attendancesheet'
ext = filename.split('.')[-1]
# get filename
if instance.pk:
filename = '{}.{}'.format(instance.pk, ext)
else:
# set filename as random string
filename = '{}.{}'.format(uuid4().hexq, ext)
# return the whole path to the file
4 matches
Mail list logo