title: reason behind "local variable 'variable ' referenced before assignmen" ERROR
body: <p>I am not much familiar with django. Was working on a learning project. So here I am getting the error which says UnboundLocalError, "local variable 'url_array' referenced before assignment" . Here's my form.py , views.py and html code. Please have a look and give me a solution.</p>
  
  <p>forms.py</p>
  
  <pre><code>from django import forms
  from .models import Images
  
  class ImageForm(forms.ModelForm):
      class Meta:
          model = Images
          fields = ('__all__')
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>class Upload(View):
  
      def post(self, request):
  
          form = ImageForm(request.POST, request.FILES)
          if form.is_valid():
              form.save()
              imageZip=request.FILES
              fs = FileSystemStorage()
              url_array = []
  
  
              with ZipFile(imageZip['image'], 'r') as zip:
                  zip.extractall()
                  unzip_file= zip.namelist()
                  for files in unzip_file:
                      with open(files, "rb") as file:
                          name = fs.save('read.jpg', file)
                      url_array.append(fs.url(name))
          else:
              form = ImageForm()
  
  
          return render(request, 'toDo_app.html', context = {'form': form, 'url':url_array})
  </code></pre>
  
  <p>toDo_app.html</p>
  
  <pre><code>&lt;form  class="" enctype="multipart/form-data" action="/upload/" method="post"&gt;
            {% csrf_token %}
            {{ form.as_p }}
            &lt;button type="submit" &gt;Upload&lt;/button&gt;
  
  
         &lt;/form&gt;
  
            &lt;br&gt;
  
            {% if url %}
              &lt;p&gt;Uploaded file: &lt;/p&gt;
              &lt;ul&gt;
                {% for urls in url %}
                  &lt;li&gt;  &lt;a href="{{ urls }}"&gt;{{ urls }}&lt;/a&gt; &lt;/li&gt;
                  {% endfor %}
  
              &lt;/ul&gt;
  
  
  
            {% endif %}
  </code></pre>
  
  <p>So my error is at <code>return render(request, 'toDo_app.html', context = {'form': form, 'url':url_array})</code> line. 
  Thanks for your time and I would be really grateful for an explanation and solution</p>