﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24690	Warn about mutable defaults with ArrayField	Bryan Rehbein	MZ	"I found an issue when upgrading to Django 1.8 and using the new ArrayField and a model's instance methods.

This code will cause Model#array_field's data to bleed between different instances.

{{{
def add_to_array(self, item):
    if item not in self.array_field:
        self.array_field.append(item)
}}}

However, this code does the correct thing:

{{{
def add_to_array(self, item):
    existing = self.array_field

    if item not in self.array_field:
        self.array_field = existing + [item]
}}}

I put together a django project/app with the code and tests that show the problems with self.array_field.append(). It also has a Vagrant file setup that should also exhibit the problems.

https://github.com/redbeard0x0a/django18bug"	Cleanup/optimization	closed	Documentation	1.8	Normal	fixed	ArrayField postgres		Accepted	1	0	0	0	0	0
