Form not populating data

else:
        recipient_alias = CustomUser.objects.filter(id=recipient).values('alias_name')[0]['alias_name']
        sender_alias = CustomUser.objects.filter(id=sender).values('alias_name')[0]['alias_name']
        context = {
            'sender': sender,
            'recipient': recipient,
            'sender_alias': sender_alias,
            'recipient_alias': recipient_alias,

        }
        print(type(context))
        form = forms.EmailNewForm(context)
        return render(request, "accounts/email_new.html", {"form": form})

<class 'dict'>

Great! Now, how do you pass the context to the render call?

I am guessing that I am not doing that. I tried passing it in the render and it renders the source code. So would I be correct in thinking that I have to pass it in the render to use it in the template?

What do the docs at Writing your first Django app, part 3 | Django documentation | Django tell you about this?

Context should go in the render to use, to my understanding, and I get this when it renders.

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</head>
<body>
    <script>(function() {var w = window,s = w.localStorage,at=Date.now()+Math.max(599.910308,0)*1000+999;w.addEventListener('load', function() {s['djalLogoutAt'] = at;function upd() {if (s['djalLogoutAt'] > at) {at = s['djalLogoutAt'];setTimeout(upd, at - Date.now());}else {delete s['djalLogoutAt'];w.location.reload();}}setTimeout(upd, at - Date.now());});})();</script>
    <nav class="navbar navbar-primary bg-primary flex-row">

          <a class="navbar-brand" href="#">
            <img class='logo' src="/media/" alt="" width="60" height="30">
          </a>


    <ul class="nav navbar-dark bg-primary flex-row-reverse">
      <li class="nav-item">
           <a class='nav-link text-white' href="/accounts/qrcode_button/">Fish QRCode</a>
      </li>
      <li class="nav-item">
          <a class='nav-link text-white' href="/logout/">Logout</a>
      </li>
      <li class="nav-item">
        <a class='nav-link text-white' href="/login/">Login</a>
      </li>
      <li class="nav-item ">
        <a class='nav-link text-white' href="#">Donate</a>
      </li>
      <li class="nav-item ">
        <a class='nav-link text-white' href="/accounts/index/">Home</a>
      </li>
    </ul>
  </div>
  </nav>
 </center></h2>
  
    <div class="container mt-2">
    <form  method="POST" >
        <input type="hidden" name="csrfmiddlewaretoken" value="GWJI0TgFYTiQ1ycZAzwLhNkmMhvdkpkgQGkai7OQFjP1i2vyWCae0fieiFMSGFDG">
        <br><h1><center>Send Email</center></h1><br>
        <center><p>
    <label for="id_sender_alias">Sender:</label>
    <input type="text" name="sender_alias" value="jeff_l0000" maxlength="50" required id="id_sender_alias">
    
      <span class="helptext">Changing text does not change sender.</span>
    
    
  </p>

  
  <p>
    <label for="id_recipient_alias">Recipient:</label>
    <input type="text" name="recipient_alias" value="scott_l2984" maxlength="50" required id="id_recipient_alias">
    
      <span class="helptext">Changing text does not change recipient.</span>
    
    
  </p>

  <ul class="errorlist"><li>This field is required.</li></ul>
  <p>
    <label for="id_orginal_message">Email Message:</label>
    <textarea name="orginal_message" cols="40" rows="10" maxlength="500" required id="id_orginal_message">
</textarea>
    
    
      <input type="hidden" name="sender" value="2" id="id_sender"><input type="hidden" name="recipient" value="36" id="id_recipient">
    
  </p></center>
        </div><br><br>
        <center><input type="submit" value="Send" style="background-color: rgb(8, 167, 8); color: white; height:38px; width:70px; padding-bottom: 6px;">
        <a href="/accounts/index/" class="btn btn-danger">Cancel</button></a></center>
        </div> 
        
    </form>
    </div>
    
    
</div>
<!-- Footer -->
<footer class="text-center text-lg-start bg-white text-muted">
  <!-- Section: Social media -->
  <section class="d-flex justify-content-center justify-content-lg-between p-4 border-bottom">
    <!-- Left -->
    <div class="me-5 d-none d-lg-block">

    </div>
    <!-- Left -->

    <!-- Right -->

  
    <!-- Right -->
  </section>
  <!-- Section: Social media -->

  <!-- Section: Links  -->
  <section class="">
    <div class="container text-center text-md-start mt-5">
      <!-- Grid row -->
      <div class="row mt-3">
        <!-- Grid column -->
        <div class="col-md-3 col-lg-4 col-xl-3 mx-auto mb-4">
          <!-- Content -->
          <h6 class="text-uppercase fw-bold mb-4">
            <i class="fas fa-gem me-3 text-secondary"></i>Company name
          </h6>
          <p>
            Here you can use rows and columns to organize your footer content. Lorem ipsum
            dolor sit amet, consectetur adipisicing elit.
          </p>
        </div>
        <!-- Grid column -->

        <!-- Grid column -->
        <div class="col-md-2 col-lg-2 col-xl-2 mx-auto mb-4">
          <!-- Links -->
          <h6 class="text-uppercase fw-bold mb-4">
            Products
          </h6>
          <p>
            <a href="#!" class="text-reset">Angular</a>
          </p>
          <p>
            <a href="#!" class="text-reset">React</a>
          </p>
          <p>
            <a href="#!" class="text-reset">Vue</a>
          </p>
          <p>
            <a href="#!" class="text-reset">Laravel</a>
          </p>
        </div>
        <!-- Grid column -->

        <!-- Grid column -->
        <div class="col-md-3 col-lg-2 col-xl-2 mx-auto mb-4">
          <!-- Links -->
          <h6 class="text-uppercase fw-bold mb-4">
            Useful links
          </h6>
          <p>
            <a href="#!" class="text-reset">Pricing</a>
          </p>
          <p>
            <a href="#!" class="text-reset">Settings</a>
          </p>
          <p>
            <a href="#!" class="text-reset">Orders</a>
          </p>
          <p>
            <a href="#!" class="text-reset">Help</a>
          </p>
        </div>
        <!-- Grid column -->

        <!-- Grid column -->
        <div class="col-md-4 col-lg-3 col-xl-3 mx-auto mb-md-0 mb-4">
          <!-- Links -->
          <h6 class="text-uppercase fw-bold mb-4">Contact</h6>
          <p><i class="fas fa-home me-3 text-secondary"></i> New York, NY 10012, US</p>
          <p>
            <i class="fas fa-envelope me-3 text-secondary"></i>
            info@example.com
          </p>
          <p><i class="fas fa-phone me-3 text-secondary"></i> + 01 234 567 88</p>
          <p><i class="fas fa-print me-3 text-secondary"></i> + 01 234 567 89</p>
        </div>
        <!-- Grid column -->
      </div>
      <!-- Grid row -->
    </div>
  </section>
  <!-- Section: Links  -->

  <!-- Copyright -->
  <div class="text-center p-4" style="background-color: rgba(0, 0, 0, 0.025);">
    © 2021 Copyright:
    <a class="text-reset fw-bold" href="https://mdbootstrap.com/">MDBootstrap.com</a>
  </div>
  <!-- Copyright -->
</footer>
<!-- Footer -->
</body>
</html>

Ok, so are you passing the context into your call to render? (Show the one statement where you are doing this.)

Python

@login_required
def email_new(request, sponsor, id):
    if request.method == "POST":
        form = EmailNewForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'index.html', {'form': form})
    else:
        form = EmailNewForm()
        return render(request, "accounts/email_new_form.html", {'form': form})

Simple Example-

Python

@login_required
def email_new(request, sponsor, id):
    if request.method == "POST":
        form = EmailNewForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'index.html', {'form': form})
        else:
            logger.error(f"Error saving email form: {form.errors}")
            return render(request, "accounts/email_new_form.html", {'form': form})
    else:
        form = EmailNewForm()
        return render(request, "accounts/email_new_form.html", {'form': form})