title: 'AnonymousUser' object is not iterable at my index
body: <p>So hello guys, Im new here at Django and while running my code i ran to this kind of error
  'AnonymousUser' object is not iterable
  it highlight my error in my index line 37. patient=Patient.objects.filter(user = request.user)</p>
  <p>so this is my views.py</p>
  <pre><code>def index(request):
  feature1 = Feature.objects.all()
  Appnt = Appointment()
  if request.user:
      patient=Patient.objects.filter(user = request.user)
      if request.method == 'POST':
          name = request.POST.get('name')
          Appnt.name = name
          email = request.POST.get('email')
          Appnt.email = email
          phone = request.POST.get('phone')
          Appnt.phone = phone
          Adate = request.POST.get('date')
          Appnt.Adate=Adate
          Dept = request.POST.get('department')
          Appnt.Dept=Dept
          Doc = request.POST.get('doctor') 
          Appnt.Doc=Doc
          Content = request.POST.get('message') 
          Appnt.Content = Content
          Appnt.ref = &quot;ref_&quot; + str(len(Appointment.objects.all()) + 1)
          Appnt.save()
          sendEmail(email, &quot;Date: &quot; + Adate + &quot;\n&quot; + name + &quot;\n&quot; + phone + &quot;\n&quot; + Dept + &quot;\n&quot; + 
          Doc + &quot;\n&quot;+ Content)
      context = {
          'feature1' : feature1,
          'Appointment' : Appnt
      }
  return render(request, 'index.html', context)
  </code></pre>
  <p>and this is my urls.py</p>
  <pre><code>path('', views.index , name='index'),
  </code></pre>