Question

I have a strange issue I've never seen before and I'm a bit stuck at where to go next.

We have a fairly standard Django app, with some forms using class based views, and we're finding that state is getting mixed between forms in strange ways.

For example, User A is on the site and fills out form X and sets their postcode.

User B goes to another form altogether, form Y, but the postcode field is already populated with User A's postcode.

The fields share the same name, but are on totally independent forms. The field in this example is a standard Django CharField.

I haven't managed to replicate this behaviour using the Django dev server locally from a little trying. I've upgraded gunicorn to latest version, I've set it to use a single worker, I've disabled caching everywhere in the Django project that I can find.

It's stuck on Django 1.3.7, and it's not a trivial app to upgrade to a supported version. It's running with gunicorn 18 behind nginx.

I've noted the Django mentions of thread safety in class based views, but I don't see us passing any mutable objects to the view, and it's all a fairly plan view and ModelForm. Django's session store is the default (it was previously something else but I removed that to use the Django default which I believe is the db).

Any ideas where to go next to try and figure this out?

Thanks!

Was it helpful?

Solution

Figured it out - turns out it was to do with the behaviour of get_initial in 1.3, which was changed in Django 1.4

https://docs.djangoproject.com/en/dev/releases/1.4/#formmixin-get-initial-returns-an-instance-specific-dictionary

We changed our get_initial to use a copy of the dict rather than the default implementation, and now all is well :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top