I am using Django's Comments Framework in my project to handle comments of a movie :
My my_comments_app/models.py looks like this :
from django.db import models
from django.contrib.comments.models import Comment
class UserExperience(Comment):
experience = models.CharField('User Experience', max_length=20)
# paginate_by = 4 | This does not work !!
def __unicode__(self):
return self.user.username
and my my_comment_app/forms.py looks like :
from django import forms
from .models import UserExperience
from django.contrib.comments.forms import CommentForm
from movies.models import Movie
from django.contrib.comments.moderation import CommentModerator, moderator
class UserExperienceForm(CommentForm):
experience = forms.CharField(max_length=20)
def get_comment_model(self):
return UserExperience
def get_comment_create_data(self):
data = super(UserExperienceForm, self).get_comment_create_data()
data['experience'] = self.cleaned_data['experience']
return data
class MovieCommentModerator(CommentModerator):
email_notification = False
auto_close_field = "start_date"
close_after = 31
moderator.register(Movie, MovieCommentModerator)
Where and when should i add paginate_by = 4 to get my comments system paginate requests ?
I am asking this because i am not using any views.py to generate my comments (as described in django docs)
How do i add pagination to the comments ?
I have tried the following:
- Pagination using views.py. By creating a view and using its
- Seeing that I am somehow using Class Based View in my UserExperience class (of which I am not sure, I might be completely wrong..) I have tried this answer too. Which is about pagination for Class Based Views.
none of them worked.
Help me paginate over my comments.