Ok, thanks. This explains what was going on. I did read that when I was first learning python, but I bet now, I won't forget about it anymore. I tried working around it, but that wasn't really working as the default value for the arguments get changed, also using messages = None wasn't an option as that would clear the message.
I am not using sessions yet, but that will probably be a later add on and could also solve the problem. My solution for now is that I added a small class (global object) that contains the arrays errors and messages. It has addError, addMessage, getError and getMessage. I call the set methods whenever I want to add a notice to the user (error or message) and I call the get method in the render_to_response statements. The get methods return the arrays and clear them. def getErrors(self): retrieve = self.errors self.errors = [] return retrieve This allows me to add all errors and messages and then display them once. This is working for me and does the job for both httpresponseredirect and render_to_response. Basic setup: view(request): if(request.POST): #do stuff setErrors, setMessages httpresponseredirect else: rendertoresponse(... { 'error_list':getErrors, 'message_list':getMessages}) cheers, Maarten On Jan 3, 7:38 pm, Peter Rowell <[EMAIL PROTECTED]> wrote: > I didn't like my own explanation and did a little more searching. > > I just found a better description of this > athttp://requires-thinking.blogspot.com/2007/10/note-to-self-default-pa.... > > He points out that the 'def' is an executable statement and it's only > executed once. Therefore, the foo=[] only happens once. > > See the Python Language Reference for the authoritative description > http://docs.python.org/ref/function.html > > Note the subsection titled "Default parameter values are evaluated > when the function definition is executed." --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---