POST function returns None, if actual dictionary is empty.
POST function returns None, if actual dictionary is empty.

It will simplify an awful lot of code. We usually do not care whether the dictionary is empty or it is set to None. However, Django forms do care. data argument, which is passed to Django forms is crucial in regard to how Django treats that form.

If supplied, the form is considered bound to data and is rendered in a different way and validated, etc. Even empty dictionary is valid data, and Django's check goes as follows:

self.is_bound = data is not None or files is not None

As a workaround, we usually type  a logical expression: data.POST or None, so None is passed in case of an empty dictionary. This change will provide a path to simplfy all these constructs.

Also, in new forms, we should avoid using instance argument. This argument is only a part of ModelForm class, i.e. not raw Form class, and we are planning to abandon that class eventually.

Instead, we provide a dictionary mapping field IDs to values and supply them to data arguemnt. An example is OrgProfileForm. This is all hacky, because we end up with the following expression:
AForm(data=data.POST or form_data)

where form_data is a dictionary with entity's data described above. There are at least a few problems with this approach. The most important one is that data should be applied to POST data which is submitted by a user.

We should actually use initial argument.

AForm(data=data.POST or None, initial=form_data).

In that case, initial will be used only if POST data is not supplied. By changing data.POST to return None, we can simplify all these calls to

AForm(data=data.POST, initial=form_data)

This change still does not argue with the actual semantics of the function. It is supposed to return POST data, so it returns NONE if no data has been posted.

rhyolight/nupic.son,rhyolight/nupic.son,rhyolight/nupic.son