Django: выводить дату последней загрузки и количество новых записей с момента последней загрузки

В моем приложении я создал рабочую функцию для выгрузки всей информации о пользователях из моей базы данных. На моей html-странице я хотел бы также добавить дату последней загрузки csv-файла и количество новых профилей, добавленных с момента последней загрузки. Я думал использовать для этого информацию, хранящуюся в файле имен, но получаю ошибку 'file_name' is not defined

account.views

@login_required
def download_csv(request):
    response = HttpResponse(content_type='text/csv')
    profile_total = Information.objects.all().count()
    profile_csv_date_donwload = str(datetime.today().strftime("%d-%m-%Y"))
    file_naname = + profile_csv_date_donwload + str(profile_total) +'.csv'
    response['Content-Disposition'] = 'attachment; filename=' + file_naname     
    
    writer = csv.writer(response, delimiter=';')

    info = Information.objects.all()

    writer.writerow(['first_name', 'last_name', 'gender', 'birthdate'])

    for i in info:
        writer.writerow([i.first_name, i.last_name, i.gender, i.birthdate])

    return response

donwload.views

from account.views import download_csv
def download_page(request):
    profile_total = Information.objects.all().count()
    latest_d_csv = file_name[0:10] 
    latest_n_csv = file_name[11:] 
        new_profile = profile_total - int(latest_n_csv)
    context = {
               'profile_total': profile_total,
               'latest_d_csv': latest_d_csv
               'latest_n_csv': latest_n_csv
               'new_profile': new_profile

               }
    return render(request, 'page/download.html', context)

html

            <div class="col-md-8">      
              <div class="row gutters-sm">  
                <div class="col-sm-6 mb-3">
                  <div class="card h-100">
                    <div class="card-body">
                      <h6 class="d-flex align-items-center mb-3">Profile CSV</h6>    
                       <br/>                      
                           <small>Profile in Database: {{ profile_total }}</small>
                           <br/>                       
                           <small>Latest Download: {{ latest_d_csv}}</small>
                           <br/>  
                           <small>New Profile: {{ new_profile }}</small>                                              
                    </div>
                  </div>
                </div>  

File_name в download_page не определено, поэтому либо вызывать эту функцию из download_cv, где file_name определено и передавать имя файла как аргумент, либо передавать его через перенаправление download_cv на download_page..

Проверьте, нет ли опечатки в строке ниже (вместо имени_файла - имя_файла) file_naname = + profile_csv_date_donwload + str(profile_total) +'.csv

Вернуться на верх