Get chosen dropdown option from Django filter

I am new to the Django and searched a lot about my problem, but could not use any of the solution.

I am using Django filter to select some of the options available and use them to recreate and show my table in the HTML output.

I have created the databse and the query, and it partially works. Whenever I try to run the app, I get the IDs of the values from the database and actual values are not returned. I am using Django 2.2.16

import django_filters
from .models import *

class OrderFilter(django_filters.FilterSet):
    class Meta:
        model = Order
        fields = '__all__'

`from django.db import models

class CodeName(models.Model): code_name = models.CharField(max_length=200, null=True)

def __str__ (self):
    return self.code_name

class FileName(models.Model): file_Name = models.CharField(max_length=200, null=True) def str (self): return self.file_Name

class Order(models.Model):

codename = models.ForeignKey(CodeName, null=True,on_delete = models.SET_NULL)
filename = models.ForeignKey(FileName, null=True,on_delete = models.SET_NULL)


def stats1(request):
    import pandas as pd

    data = {
      "calories": [420, 380, 390],
      "duration": [50, 40, 45]

    #load data into a DataFrame object:
    NoneConceptsTable1 = pd.DataFrame(data)
    myFilter = OrderFilter()
    if len(NoneConceptsTable1)>0:
        print("Yes, the lenght of NoneConceptsTable1 was geater than 1")
        pos = NoneConceptsTable1.Frequency.values
        codeName_instance = list(NoneConceptsTable1.Name.values)
        # print(codeName_codeName_instance[i]instance)
% I need help after this. I want to get the selected codes from HTML and use them to filter the table: NoneConceptsTable1 
        req = request.GET
        fileName_instance = list(NoneConceptsTable1.filename.values)
        context = {'result_present': True,
          'df': NoneConceptsTable1.to_html(table_id= "table_id"),'myFilter':myFilter}
        # context = {'myFilter':myFilter}
        return render(request, 'stats1.html',context)

I want to get the selected words, but instead I get some unwanted numbers of option IDs like shown below enter image description here

Please let me know any solution you have including any available app.

Back to Top