docs: def signup(request):
      """
      Create a new user with the given credentials.
  
      GET parameters:
          html
              turn on the HTML version of the API
  
      POST parameters (JSON):
          username:
              user's name
          email:
              user's e-mail
          password:
              user's password
          password_check:
              user's password again to check it
          first_name (optional):
              user's first name
          last_name (optional):
              user's last name
      """
      if request.method == 'GET':
          return render(request, 'user_signup.html', {}, help_text=signup.__doc__)
      elif request.method == 'POST':
          if request.user.is_authenticated() and hasattr(request.user, "userprofile"):
              return render_json(request, {
                  'error': _('User already logged in'),
                  'error_type': 'username_logged'
              }, template='user_json.html', status=400)
          credentials = json_body(request.body.decode("utf-8"))
          error = _save_user(request, credentials, new=True)
          if error is not None:
              return render_json(request, error, template='user_json.html', status=400)
          else:
              auth.login(request, request.user)
              request.method = "GET"
              return profile(request, status=201)
      else:
          return HttpResponseBadRequest("method %s is not allowed".format(request.method))