Пример #1
0
 def forwards(self, orm):
     "Write your forwards methods here."
     levenshteins = orm.Levenshtein.objects.filter(ratio=None)
     for levenshtein in levenshteins:
         levenshtein.ratio = levenshte_ratio(levenshtein.text_1,
                                             levenshtein.text_2)
         levenshtein.save()
 def forwards(self, orm):
     "Write your forwards methods here."
     levenshteins = orm.Levenshtein.objects.filter(ratio=None)
     for levenshtein in levenshteins:
         levenshtein.ratio = levenshte_ratio(levenshtein.text_1,
                                             levenshtein.text_2)
         levenshtein.save()
Пример #3
0
 def post(self, request, *args, **kwargs):
     self.form = LevenshteinForm(request.POST)
     if self.form.is_valid():
         levenshtein = self.form.save()
         levenshtein.distance = levenshte_in_distance(
             levenshtein.text_1, levenshtein.text_2)
         levenshtein.ratio = levenshte_ratio(levenshtein.text_1,
                                             levenshtein.text_2)
         levenshtein.save()
     return super(LevenshteinView, self).get(request, *args, **kwargs)
Пример #4
0
 def post(self, request, *args, **kwargs):
     self.form = LevenshteinForm(request.POST)
     if self.form.is_valid():
         levenshtein = self.form.save()
         levenshtein.distance = levenshte_in_distance(
             levenshtein.text_1, levenshtein.text_2)
         levenshtein.ratio = levenshte_ratio(
             levenshtein.text_1, levenshtein.text_2)
         levenshtein.save()
     return super(LevenshteinView, self).get(
         request, *args, **kwargs)