Мне удалось исправить это, не изменяя представление, добавив в мою форму чистый метод:
class SolutionForm(forms.ModelForm):
class Meta:
model = Solution
exclude = ['problem']
def clean(self):
cleaned_data = self.cleaned_data
try:
Solution.objects.get(name=cleaned_data['name'], problem=self.problem)
except Solution.DoesNotExist:
pass
else:
raise ValidationError('Solution with this Name already exists for this problem')
# Always return cleaned_data
return cleaned_data
Единственное, что мне нужно сделать сейчас в представлении, - добавить свойство проблемы к перед выполнением is_valid
.
Вот мой путь:
Скажем, имя ответвления develop
.
# Create a new temp branch based on one history commit
git checkout <last_known_good_commit_hash>
git checkout -b develop-temp
# Delete the original develop branch and
# create a new branch with the same name based on the develop-temp branch
git branch -D develop
git checkout -b develop
# Force update this new branch
git push -f origin develop
# Remove the temp branch
git branch -D develop-temp