title: Django smart_str 'NoneType' object has no attribute
body: <p>In django, I want to download the data to excel using the smart_str, but some record of user dont have data or blank some field like in the error below, how can i do with smart_str which should be unnecessary or error free if no data can be detected?</p>
  <pre><code>def downloadcv(request):
      response = HttpResponse(content_type='text/csv')
      # decide the file name
      response['Content-Disposition'] = 'attachment; filename=&quot;StudentEnrollmentRecord.csv&quot;'
  
      writer = csv.writer(response, csv.excel)
      response.write(u'\ufeff'.encode('utf8'))
      writer.writerow([
         smart_str(u&quot;Guardians_Fullname&quot;),
         smart_str(u&quot;Guardians_Address&quot;),
         smart_str(u&quot;Contact_Number&quot;),
      ])
      reports = StudentsEnrollmentRecord.objects.filter(School_Year=yearid).order_by('Education_Levels','-Date_Time')
      for report in reports:
          last_name = report.Student_Users.Parent_Users.Guardian_LastName or &quot;&quot;
          first_name = report.Student_Users.Parent_Users.Guardian_FirstName or &quot;&quot;
          initial = report.Student_Users.Parent_Users.Guardian_Middle_Initial or &quot;&quot;
          writer.writerow([
          smart_str(last_name, first_name, initial),
      return response if response is not None else 'None'
  </code></pre>
  <p>this is the error i get</p>
  <p><a href="https://i.stack.imgur.com/YNDJP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YNDJP.png" alt="enter image description here" /></a></p>