Я ошибки в джанго-формах проверяю следующим образом:
делаю
И в методе-обработчике формы проверяю — если метод get, то просто отобразить данные, если post — то проверить, и, в случае валидности формы, показать. Иначе вывести ошибки.
def object_edit_or_add_post_save(self, request, entity_name, object_id=None):
self.check_the_entity(entity_name)
if request.method == 'GET':
""" если GET, то запрашивается страница """
return self.object_edit_or_add(request, entity_name, object_id)
elif request.method == 'POST':
""" если POST, то передаются данные """
return self.object_save(request, entity_name, object_id)
def object_save(self, request, entity_name, object_id=None):
...
if f.is_valid():
f.save()
return HttpResponseRedirect(self.root + entity_name)
else:
# ищем ошибки
for e, e_message in f.errors.items():
field = f.fields[e]
field.error = True
field.error_message = e_message
...
Выяснилось, что все сложнее, чем казалось. Проблема NP полная, а под рукой вычислительного кластера нет.
Original song The longest Time
Original artist Billy Joel
— Woh, oh-oh-oh
Find the Longest Path
Woh oh-oh
Find the Longest Path
If you said P is NP tonight
There would still be papers left to write
I have a weakness
I'm addicted to completeness
And I keep searching for the longest Path
The algorithm I would like to see
Is of Polynoimal Degree
Buts its elusive,
Nobody has found conclusive
Evidence that we can find the Longest Path
I have been hard
Working for so long
I swear its right,
But he marks it wrong
Somehow I'll feel sorry when its done
GPA 2.1,
Is more than I hoped for
Garey, Johnson, Karp and other Men (and Women)
Try to make it Order n log n.
Am I a math fool
If I spend my life in Grad School
Forever following the Longest Path.
Woh oh-oh-oh
Find the longest path
Woh oh-oh-oh
Find the longest path
Это я уже понял, когда обнаружил, что от одного объекта может быть несколько связей. Просто из изначальной формулировки это не очень ясно, хотя и можно было бы предположить.
Я так понимаю, я свою попытку уже исчерпал, но ради интереса я переделаю свой алгоритм для правильной обработки.
делаю
И в методе-обработчике формы проверяю — если метод get, то просто отобразить данные, если post — то проверить, и, в случае валидности формы, показать. Иначе вывести ошибки.
pastebin.com/WaLgEEzr
Original song The longest Time
Original artist Billy Joel
— Woh, oh-oh-oh
Find the Longest Path
Woh oh-oh
Find the Longest Path
If you said P is NP tonight
There would still be papers left to write
I have a weakness
I'm addicted to completeness
And I keep searching for the longest Path
The algorithm I would like to see
Is of Polynoimal Degree
Buts its elusive,
Nobody has found conclusive
Evidence that we can find the Longest Path
I have been hard
Working for so long
I swear its right,
But he marks it wrong
Somehow I'll feel sorry when its done
GPA 2.1,
Is more than I hoped for
Garey, Johnson, Karp and other Men (and Women)
Try to make it Order n log n.
Am I a math fool
If I spend my life in Grad School
Forever following the Longest Path.
Woh oh-oh-oh
Find the longest path
Woh oh-oh-oh
Find the longest path
Я так понимаю, я свою попытку уже исчерпал, но ради интереса я переделаю свой алгоритм для правильной обработки.
00F3C466 00F3C46B 4EA80AD3 vs 00F3C466 00F3C466 F81F6EFD
00FE4CC9 00FE4CCA 926E73B3 vs 00FE4CC9 00FE4CC9 2D13A897
0008F9D0 00FC272B 0000021B vs 0008F9D0 0008F9C9 954084D3