Problem viewing data model in select in html edit form

Good evening everyone

I have this case

class Organization(models.Model):
    organization_id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=160)
    class Meta:
        db_table = "organization"
    def __str__(self):
        return self.name

class BusinessUnit(models.Model):
    business_unit_id = models.AutoField(primary_key=True)
    organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True)
    name = models.CharField(max_length=160)
    description = models.TextField(null=True, blank=True)
    division_name = models.CharField(max_length=100, null=True, blank=True)
    credit_limit = models.FloatField(null=True, blank=True)
    cost_center = models.CharField(max_length=100, null=True, blank=True)
    web_site_url = models.URLField(max_length=200, null=True, blank=True)
    ftp_site_url = models.URLField(max_length=200, null=True, blank=True)
    email_address = models.EmailField(max_length=100, null=True, blank=True)
    class Meta:
        db_table = "businessunit"
    def __str__(self):
        return self.name

views.py

def BusinessUnitEdit(request, business_unit_id):  
    businessunit = BusinessUnitv.objects.get(business_unit_id=business_unit_id)
    queryset = Organizationv.objects.all()
    context= {'Organization': queryset}
    return render(request,'BusinessUnitEdit.html', {'businessunit':businessunit})

BusinessUnitEdit.html

    <div class="form-group row"> 
      <label class="col-sm-2 col-form-label">Organization:</label>   
    <div class="col-sm-4">
      {%for itens in businessunit %}
      <option value="{{businessunit.business_unit_id}}" name='{{businessunit.name}}'>{{businessunit.name}}</option>
      {%endfor%}
    </div>  
  </div>  

However, in no way can I view the data in this table name organization

Can anyone help?

Welcome @tiagoceluppi !

Side note: When posting code (or templates, error messages, tracebacks, etc), enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. (I’ve taken the liberty of editing your original post. Please remember to do this in the future.)

I’m not following what your issue is relative to the template you’re showing here.

Also, it appears you have a number of typos in the code you’ve posted. Please copy/paste the actual code that you’re having issues with. It’s a lot easier to debug things that way without trying to figure out what errors are simply being caused by having tried to retype the code.

Yes, in the model I am putting the select tag, but no matter how I write it, it does not return any record from the organization table, and therefore in the select it does not return any value, I don’t know if my problem is in view.py or in writing the code in python in html.

BusinessUnitEdit.html

{% load static %}

Index
<link rel="stylesheet" href="{% static 'css/style.css' %}"/>  
{% csrf_token %}

Update Data

Organization:
{%for itens in businessunit %} {{businessunit.name}} {%endfor%}
Name:
Description:
Division Name:
Credit Limit:
Cost Center:
Web Site Url:
Ftp Site Url:
Email Address:
Update

I try to view the result in my view

views.py

def BusinessUnitEdit(request, business_unit_id):
businessunit = BusinessUnitv.objects.get(business_unit_id=business_unit_id)
organization = Organizationv.objects.all()
for organization in organization:
print(f’{organization.name}')
return render(request,‘BusinessUnitEdit.html’, {‘businessunit’:businessunit})

Result in log
Empresa
Empresa 1
Empresa 3
Empresa 3

and change code in BusinessEdit.htm

<div class="col-sm-4">
  <select name="organization" id="id_organization" class="form-control">
    {% for organization in organization %}
      <option value="{{ organization.name }}" {% if organization.organization_id == businessunit.organization_id %}selected{% endif %}>{{ organization.name }}</option>
    {%endfor%}
  </select>
</div>  

But, the fields still don’t appear, does anyone know why?

Resolvido.

Foi a contrução da view, mais consegui achar o problema.