District Nine is based on a shorter (15 minutes) movie by the same (South African) director called “Alive in Joburg,” concerning the reaction to and mistreatment of a group of, well, homeless and also listless aliens who had take up residence, along with their ship.
It, like D9, is documentary-esque, though “Alive” was actually crafted by taking real people of various ethnic and racial backgrounds in South Africa and asking them their thoughts on Apartheid, other ethnicitys, etc.
Those responses were then carefully edited around so that the lead questions were “what do you think of these extraterrestrials” rather than “how do you feel about the Afrikaners?” District Nine is just a larger expansion upon these earlier themes of remixed-documentary-alien-racism.
As such, all of the vitrol, hate, and strangeness in D9 is, in some sense, directly based on the tense feelings of various groups in South Africa around the handling of race, class, etc.