title: django please look at the Index Error i am getting institutes ip admin module for edit and save ip address and validation
body: <p>I get this error:</p>
  
  <blockquote>
    <p>Exception Type: IndexError at /institutes_admin/ Exception Value: list
    index out of range</p>
  </blockquote>
  
  <p>Here are some details about the error:</p>
  
  <p>Environment:</p>
  
  <blockquote>
    <p>Request Method: GET Request URL:
    <a href="http://127.0.0.1:8000/institutes_admin/" rel="nofollow noreferrer">http://127.0.0.1:8000/institutes_admin/</a>
    Django Version: 1.1.1 Python Version:
    2.6.5 Installed Applications: ['django.contrib.auth', 
    'django.contrib.admin', 
    'django.contrib.contenttypes', 
    'django.contrib.markup', 
    'django.contrib.sessions', 
    'django.contrib.sites', 
    'django.contrib.comments', 
    'mysite.registration', 
    'mysite.profiles',  'mysite.epw', 
    'mysite.remember_me', 
    'mysite.avatar', 
    'mysite.django_documents', 
    'mysite.inlines',  'mysite.blog', 
    'mysite.forum',  'tagging'] Installed
    Middleware:
    ('django.middleware.cache.UpdateCacheMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'mysite.remember_me.views.AutoLogout')</p>
    
    <p>Traceback: File
    "/usr/lib/pymodules/python2.6/django/core/handlers/base.py"
    in get_response
      92.                 response = callback(request, *callback_args,
    **callback_kwargs) File "/usr/lib/pymodules/python2.6/django/utils/decorators.py"
    in _wrapped_view
      48.                 response = view_func(request, *args, **kwargs)
    File
    "/home/karthik/Desktop/mysite/../mysite/epw/admin_views.py"
    in institutional_ip_admin
      614.        arranged_list = arrange_ips(chk_exist_obj) File
    "/home/karthik/Desktop/mysite/../mysite/epw/admin_views.py"
    in arrange_ips
      582.                total_value += (map_range(institute_obj, index), )
    File
    "/home/karthik/Desktop/mysite/../mysite/epw/admin_views.py"
    in map_range
      558.        ip_value = ip_list_read(institute_obj,
    list_value, index) File
    "/home/karthik/Desktop/mysite/../mysite/epw/admin_views.py"
    in ip_list_read
      548.        ip_value.append(str(object_persistance(getattr(institute_obj,
    list_value + str(i)))[index-1]))</p>
    
    <p>Exception Type: IndexError at
    /institutes_admin/ Exception Value:
    list index out of range</p>
  </blockquote>
  
  <p>module I am working on:</p>
  
  <pre><code>def institutional_ip_admin(request, form_class = Institutional_Subscription_Form,template_name
      = "institutional_subscription.html"):   
  
      current_user = request.user
      super_user, admin_user, dict_user = chk_admin_user(current_user)
  
      if (super_user and admin_user) or (not super_user):       
          return HttpResponseRedirect("/admin_access/")
  
      update_user_id = request.session['update_user_id'] 
      result_of_update, result_of_category, result_of_cover, result_of_latest, result_of_block, result_of_footer, result_of_research = common_blocks()
      ip_type = request.POST.get('ip_type')
      update_user = User.objects.get(id = update_user_id)
      chk_exist_obj = institutional_subscription.objects.filter(user__id=update_user_id).order_by('-id')
      redirect_location = '/success/update_subscription/'
      arranged_list = []
  
      if chk_exist_obj:
          chk_exist_obj = chk_exist_obj[0]
          ip_type = chk_exist_obj.ip_type
          arranged_list = arrange_ips(chk_exist_obj)
                          print arranged_list
  
      if request.method == "POST":
  
          form = form_class(data=request.POST)
  
          if request.POST.get('ip_type') == 'edit':
              data_dict = map_ip_attrs(request.POST)
              result_dict = ip_seperate(data_dict, chk_exist_obj.ip_type)
              chk_exist_obj.from1 = str(result_dict['from1'])
              chk_exist_obj.from2 = str(result_dict['from2'])
              chk_exist_obj.from3 = str(result_dict['from3'])
              chk_exist_obj.from4 = str(result_dict['from4'])
              chk_exist_obj.to1 = str(result_dict['to1'])
              chk_exist_obj.to2 = str(result_dict['to2'])
              chk_exist_obj.to3 = str(result_dict['to3'])
              chk_exist_obj.to4 = str(result_dict['to4'])
              chk_exist_obj.access_limit = request.POST.get('access_limit')
              chk_exist_obj.save()
  
              new_id = chk_exist_obj.id
              old_user = chk_exist_obj.user
              delete_old_records = institutional_subscription.objects.filter(user= old_user).exclude(id = new_id).delete()
              return render_to_response('successful.html', {'user' : current_user, 'editsuccess':'Ips are updated successfully','result_of_update' : result_of_update, 'result_of_category' : result_of_category, 'result_of_cover' : result_of_cover, 'result_of_latest':result_of_latest, 'result_of_block' : result_of_block, 'result_of_footer':result_of_footer,  'result_of_research' : result_of_research, })
  
          elif form.is_valid():
              data_dict = form.cleaned_data
              ip_type = request.POST.get('ip_type')
              result_dict = ip_seperate(data_dict, ip_type)
              ip_obj = institutional_subscription(
  
                          user = update_user, 
  
                          from1 = str(result_dict['from1']), 
  
                          from2 = str(result_dict['from2']), 
  
                          from3 = str(result_dict['from3']), 
  
                          from4 = str(result_dict['from4']),
  
                          to1 = str(result_dict['to1']),
  
                          to2 = str(result_dict['to2']),
  
                          to3 = str(result_dict['to3']),
  
                          to4 = str(result_dict['to4']),
  
                          access_limit = request.POST.get('access_limit'),
  
                          ip_type = ip_type
              )
  
              ip_obj.save()
              new_id = ip_obj.id
              old_user = update_user  
              delete_old_records = institutional_subscription.objects.filter(user = old_user).exclude(id = new_id).delete()
              return render_to_response('successful.html', {'user' : current_user, 'editsuccess':'Ips are updated successfully','result_of_update' : result_of_update, 'result_of_category' : result_of_category, 'result_of_cover' : result_of_cover, 'result_of_latest':result_of_latest, 'result_of_block' : result_of_block, 'result_of_footer':result_of_footer,  'result_of_research' : result_of_research, })  
  
      else:
          form = form_class()
  
      pageinfo = "SubscriptionInstituteIpRange"    
      return render_to_response(template_name, {'user' : current_user, 'form' : form, 'result_of_category':result_of_category, 'result_of_update' : result_of_update, 'result_of_category' : result_of_category, 'result_of_cover' : result_of_cover, 'result_of_latest':result_of_latest, 'result_of_block' : result_of_block, 'result_of_footer':result_of_footer, 'result_of_research' : result_of_research, 'chk_exist_obj' : chk_exist_obj, 'arranged_list' : arranged_list, 'super_user' : super_user, 'redirect_location' : redirect_location})
  </code></pre>