insert problem with mysql db

class AddSectors(models.Model):

    sectorName = models.CharField(max_length=200)

    uDate = models.DateTimeField()

# only  admin can add Category name with sectors name

class AddCategory(models.Model):

    sectorId = models.ForeignKey(AddSectors, on_delete=models.CASCADE, null=True)

    categoryName = models.CharField(max_length=200)

    date = models.DateTimeField()

if 'addCategoryBtn' in request.POST:

        inputCategoryName = strip_tags(request.POST.get("CategoryName"))

        inputSelectSectorId = strip_tags(request.POST.get("selectSectorId"))

        addCategoryQuery = AddCategory(sectorId = inputSelectSectorId , categoryName = inputCategoryName,  date = )

        messages.success(request, 'Sector Added Successfully')

 showAllSector = AddSectors.objects.all()
 dataArray = {
        'showAllSectorss': showAllSector
return render(request, "adminTemplates/addSectorCategory.html", dataArray )


<div class="col-6">
<select class="form-select form-select-sm" name="selectSectorId" >
<option selected>Sectors Name</option>
 {% for forSector in showAllSectorss %}
     <option value="{{}}">{{ forSector.sectorName }}</option>
 {% endfor %} 

and then when i select sector and type category name pressed the button got this error

ValueError at /AddSectorCategory

Cannot assign “‘1’”: “AddCategory.sectorId” must be a “AddSectors” instance.

  • D:\11 august 2021\workspace\python django projects\reffral\reff\home\ , line 521, in adminAddSectorCategory
  1. addCategoryQuery = AddCategory(sectorId = inputSelectSectorId , categoryName = inputCategoryName, date = )

How to Solve this problem sir

You can use the foreign key field name (sectorId_id) rather than the foreign key (sectorId) in the constructor at that line.

problem solved thanks sir