Fixed #21832

1st commit: Updates code, tests and docs.
2nd commit: Way to create fk instance at command line.
I am going to remove this condition as I think that its not required. The while loop already checks `username is None` so just after that there is no need for `if not username`.