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 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)
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)