Ticket 23829

This pull requests fixes the actual problem with #23829 and also makes the command work if django.contrib.sites is not installed.

`django.contrib.sites` will default to the current requests to get the domain, but this is not applicable when running as a management command.

I could not find any existing tests for this, so I did not know which tests to enhance. However, I will work on writing some mocks to ensure that the request is being passed correctly.
It's probably better to move the new kwargs to the end, as some people might depend on the ordering...