Django Deserializer Bug On Foreign Key When None
THis is more for myself than anyone else but remind me to submit this to the bug list. Or at least check if it exists already. When deserializing a model with a foreign key whose value is set to None I get the following exeption:
The Bug
The Fix
I needed a fix quick and I’m not sure this is the best way to do it. The error is at:
The code was attempting to do an object lookup on a key value of None. The exception only checks for does not exist but for some reason the code was returning them all. I added a check to see if the value of the key is None to prevent a lookup in the first place. The following fixed the issue:
More from Aware Labs
- Retiring Old Posts To Keep Django Fresh
- Constructive reasons to use Django instead of Rails (Proxied)
- Django Generic Relations Made Easier
- WordPress Adventure – NoScript Hack Solved
- What Is Your Version Of Django
Aware Labs Recommends
- Popularizing Django — Or Reusable apps considered harmful. (USwaretech)
- Django’s tipping point (Antonio Cangiano)
- An Interview with Jacob Kaplan-Moss – Creator of Django (USwaretech)
-
Nobody

![Recommend [AwareLabs]](http://s3.amazonaws.com/arkayne-media/img/badge/logo-recommend-badge-medium.png)