2

I'm working with my Team on a Django Project and we have a Problem. So two of us, me included are working on macOS. Our Code is working just fine on macOS and we pushed it on git. But the others that are working on windows are getting a list index out of range error. Everybody has the same Version. Is it maybe because macOS and windows have different Libraries?

def getStand(self, getränk):
    with open("machine/Lagerverwaltung.csv", "r") as file:
       reader = csv.reader(file)
       next(reader)
       count = 0
       for line in reader:
            count += 1
            if count == getränk:
                return float(line[2])
            else:
                continue

Traceback:

Watching for file changes with StatReloader
Internal Server Error: /
Traceback (most recent call last):
File "C:\Users\-\AppData\Local\Programs\Python\Python38\lib\site- 
packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\-\AppData\Local\Programs\Python\Python38\lib\site- 
packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\-\AppData\Local\Programs\Python\Python38\lib\site- 
packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\-\Desktop\vending\vendingmachine\machine\views.py", line 17, in main
context = {"cola": l.getStand(1), "fanta": l.getStand(2), "sprite": l.getStand(3), "pepsi": 
l.getStand(4), "limit": l.literLimit}
File "C:\Users\-\Desktop\vending\vendingmachine\machine\views.py", line 154, in getStand
return float(line[2])
IndexError: list index out of range
[14/Jun/2020 12:45:56] "GET / HTTP/1.1" 500 77982
Phoenix
  • 3,996
  • 4
  • 29
  • 40
Danii O.
  • 23
  • 5

0 Answers0