Skip to content

Instantly share code, notes, and snippets.

@cesandoval
Created August 6, 2012 20:47
Show Gist options
  • Save cesandoval/3278290 to your computer and use it in GitHub Desktop.
Save cesandoval/3278290 to your computer and use it in GitHub Desktop.
shp file review error
> I'm getting an error while trying to access the review page after uploading files. I get a list index out of range error. I'm guessing that this is happening because the script can't access any of the items I uploaded to the webpage, maybe the database is empty? How do you think I might be able to solve this? Here's the error:
> IndexError at /webfinches/review/
>
> list index out of range
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/webfinches/review/
> Django Version: 1.4
> Exception Type: IndexError
> Exception Value:
>
> list index out of range
>
> Exception Location: c:\Python27\lib\site-packages\django\db\models\query.py in __getitem__, line 207
> Python Executable: c:\Python27\python.exe
> Python Version: 2.7.2
> Python Path:
>
> ['c:\\Users\\carlos\\projects\\localcode',
> 'c:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
> 'C:\\Users\\carlos\\projects',
> 'C:\\Windows\\system32\\python27.zip',
> 'c:\\Python27\\DLLs',
> 'c:\\Python27\\lib',
> 'c:\\Python27\\lib\\plat-win',
> 'c:\\Python27\\lib\\lib-tk',
> 'c:\\Python27',
> 'c:\\Python27\\lib\\site-packages']
>
> Server time: Mon, 6 Aug 2012 13:28:37 -0700
> Traceback Switch to copy-and-paste view
>
> c:\Python27\lib\site-packages\django\core\handlers\base.py in get_response
>
> response = callback(request, *callback_args, **callback_kwargs)
>
> ...
> ▶ Local vars
> c:\Python27\lib\site-packages\django\contrib\auth\decorators.py in _wrapped_view
>
> return view_func(request, *args, **kwargs)
>
> ...
> ▶ Local vars
> c:\Users\carlos\projects\localcode\webfinches\views.py in review
>
> upload = UploadEvent.objects.filter(user=user).order_by('-date')[0]
>
> ...
> ▶ Local vars
> c:\Python27\lib\site-packages\django\db\models\query.py in __getitem__
>
> return list(qs)[0]
>
> ...
> ▶ Local vars
>
@cesandoval
Copy link
Author

Still can't make it work...

def upload(request):
"""A view for uploading new data.
"""
user=User.objects.get(username='carlos')
#print request
if request.method == 'POST':
upload = UploadEvent(user=user)
formset = ZipFormSet(request.POST, request.FILES)
for form in formset:
if form.is_valid():
data_file = form.save(upload)

else:
    formset = ZipFormSet()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment