Since the "next" field was missing, any login always redirected to the
default account page, even though it came with a "next" parameter that
would allow it to go to the correct place.
<div class="form-row">
<label for="id_password">Password:</label> <input type="password" name="password" id="id_password" />
<input type="hidden" name="this_is_the_login_form" value="1" />
+ <input type="hidden" name="next" value="{{next}}" />
</div>
<div class="submit-row">
<label> </label><input type="submit" value="Log in" />