I am trying to break pages into a class. Here's what my look looks like:
class IssuesByTitleView(ListView): context_object_name = "issue_list" def issues(request): issue_list = Issue.objects.all()
Here is an example of my models for some context:
class Title(models.Model): CATEGORY_CHOICES = ( ('Ongoing', 'Ongoing'), ('Ongoing - Canceled', 'Ongoing - Canceled'), ('Limited Series', 'Limited Series'), ('One-shot', 'One-shot'), ('Other', 'Other'), ) title = models.CharField(max_length=64) vol = models.IntegerField(blank=True, null=True, max_length=3) year = models.CharField(blank=True, null=True, max_length=20, help_text="Ex) 1980 - present, 1980 - 1989.") category = models.CharField(max_length=30, choices=CATEGORY_CHOICES) is_current = models.BooleanField(help_text="Check if the title is being published where Emma makes regular appearances.") slug = models.SlugField() class Meta: ordering = ['title'] def get_absolute_url(self): return "/titles/%s" % self.slug def __unicode__(self): class Issue(models.Model): title = models.ForeignKey(Title) number = models.CharField(max_length=20, help_text="Do not include the '#'.") ...
Of course, following the Django docs, the pagination system works when the view is defined as follows: def view(request):
I am also wondering how I can pull out the next and previous objects.
I need a link to “next issue (with context of name and release number)” and then a link to “previous issue”. Please note that simply changing the template link with the next or previous problem number will not work.
So, if anyone can help me, it will be great.