> Den 07/11/2014 kl. 10.08 skrev termopro <
term...@gmail.com>:
>
> I have a view in Django which calls external library/class. The problem is that for some reason Django keeps caching results coming from previous calls of that class.
This is expected Python behaviour - see
https://docs.python.org/3/tutorial/classes.html#class-and-instance-variables
To start with an empty result list on every class instantiation, you need to stick it into __init__:
class Demo():
def __init__(self):
self.result = []
def do_something(self):
self.result.append(1)
Erik