Answer the question
In order to leave comments, you need to log in
How to make reviews with verification by email?
Added reviews to the site on the site:
class Review(models.Model):
name = models.CharField(max_length=300, verbose_name='Имя')
school = models.ForeignKey(School, verbose_name='Школа')
email =models.EmailField(verbose_name='Почта')
body = models.TextField(verbose_name='Описание')
class ReviewAdd(CreateView):
model = Review
form_class = ReviewAddForm
template_name = 'school/review_add.html'
def form_valid(self,form):
self.object = form.save(commit=False)
school = get_object_or_404(School, slug=self.kwargs['slug'])
self.object.school = school
self.object.save()
return super(ReviewAdd, self).form_valid(form)
class ReviewAddForm(forms.ModelForm):
class Meta:
model = Review
fields = '__all__'
exclude = ['school']
Answer the question
In order to leave comments, you need to log in
1. Add a Verificated field to the Review model, which will initially be set to False.
2. Send an email with the ID of the created record, and in order not to be faked, for example, add md5 from the Review fields
3. When the user clicked on the link, check the ID and MD5 for him.
4. If everything is fine, then change the value of the Verificated field to True
5. Show the "Review published" page
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question