export txt file to specific location

Hello,
how to export a txt file or csv file to a specific location.
I can generate a txt file but i need to put it to e specific location

I think we need more details and specific information here.

Are you talking about exporting the file in a view? Or using a management command?

What exactly are you trying to do?

I have function already work correctly, when I clic in bouton exprot to txt file I can export all data to the default path for exemples downloads folder,
But I need to export my txt file to a specific path.
this is my function :
#############export txt txt txt ################
@login_required(login_url=’/authentication/login’)
def export_txt(request, pk_test):

response = HttpResponse(content_type='text/plain')
response['Content-Disposition'] = 'attachment; filename=Interventions' + \
    str(datetime.now())+'.txt'
response['Content-Transfert-Encoding'] = 'binary'
intervention = Intervention.objects.get(id=pk_test)
detailinterventions = intervention.detailintervention_set.filter().exclude(piecerechange=None)
stat = intervention.I_Status
   lines = []
if stat=='Cloturée':
    messages.success(request, 'deja exporté')
    return redirect('interventions')

else:
    for detail in detailinterventions:
        lines.append(f'{detail.piecerechange.p_code};{detail.piecerechange.p_emplacement};{detail.D_qte}\n')
    response.writelines(lines)
    messages.success(request, 'Export saved successfully')
    return response
return HttpResponseRedirect(request.path_info)

Ok, so what you’re talking about is that you want the browser to download the file from the server to a specific location identified by the server, on the client computer.

Can’t be done. The browser’s not going to allow it.

It would be an extreme security vulnerability to allow the server to dictate where a downloaded file is to be placed.

by default it take downloads folder, so how can we change this path to another path or otherway when we clic on this bouton create this file into a specific path

You can’t.

For a browser to allow that to be done would be bad.

That is something only under the control of the user.