具有unique = True更新错误的Django CharFIeld,“具有该名称的实例已存在”

I'm building a Django project for a client that requires me to not user a simple form.save() method to update a model field.

基本上,它看起来像这样:

I have this model with a CharField who has unique=True:

# models.py

class Course(models.Model):
    name = models.CharField(max_length=20, unique=True)
    other_field = models.CharField(max_length=10, null=True)

    def __str__(self):
        return self.name

That model has a form in forms.py:

# forms.py

class CourseCreateForm(forms.ModelForm):
    class Meta:
        model = Course
        fields = ['name', 'other_field']

I need to update this field through a function view (can't be class based in this scenario. Of course, literally it can, but for my student's project requirements it can't be) and I can't use the simple form.save() function, so I need to do the full update code as if it was a normal form:

# views.py

def course_update(request, pk):
    course = Course.objects.get(pk=pk)
    course_queryset = Course.objects.filter(pk=pk)


    if request.method == "POST":
        form = CourseCreateForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            other_field = form.cleaned_data['other_field']
            course_queryset.update(name=name, other_field=other_field)  # <-- Where I try to update
        else:
            print(form.errors)
        return HttpResponseRedirect('../')
    else:
        form = CourseCreateForm(instance=course)

        context = {
            "form": form,
        }

        return render(request, 'base/course_update.html', context)

When I try to only update the other_field, the change isn't made and in the formerrors I receive the error "Course with this Name already exists.", so I can't only change the other_field data without also having to change the name field because the name field is unique.

如何在不更改唯一值的情况下更新具有unique = True的模型实例的字段?

希望这有道理!

谢谢。

更新:

还想补充一点,当关闭unique = True时,它可以很好地工作。我很好奇,当unique = True并且要从模型表单中添加相同的变量时,如何正常更新字段。