Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4532208
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:00:01+00:00 2026-05-21T14:00:01+00:00

I know this is a very basic concept in Django, and I have tried

  • 0

I know this is a very basic concept in Django, and I have tried the tutorial but it is not working. I am working on a comic book database with the models set like this (at least, a sample of two of the models):

Class Title(models.Model):
    title = models.CharField(max_length=256)
    vol = models.IntegerField("Vol.")
    slug = models.SlugField(blank=True, null=True) 
    #desc = models.CharField(max_length=256)   
    class Meta:
        ordering = ['title']
    def get_absolute_url(self):
        return "/comics2/title/%s" % self.slug        
    def __unicode__(self):
        return self.title


class Issue(models.Model):
    title = models.ForeignKey(Title)
    number = models.IntegerField(help_text="Enter the number only. Do not include the hashtag.")
    writer = models.ManyToManyField(Creator)

What I am trying to do is create a page that shows a list of all the issues within that Title.

But, I have it setup in the views like this:

class AstonishingXMenIssueListView(ListView):

    context_object_name = "astonishing_list"
    queryset = Issue.objects.filter(title__title="Astonishing X-Men").order_by("number")
    template_name = "comics2/astonishing_list.html"

My urls.py look like this:

(r'^comics2/title/(?P<title_slug>[-\w]+)/$', AstonishingXMenIssueListView.as_view(
    )), 

Of course, going to /uncanny-xmen-v1/ shows the same thing as the Astonishing link above.

Obviously, this is not a practical way to list issues by title for future issues and titles, so I need it setup so that I don’t have to individually do this. Now, I have tried following the Django generic views tutorial, but I got an index tuple error.

I’ve tried this, but it doesn’t work. This is what gets me the index tuple error.

class IssuesByTitleView(ListView):

    context_object_name = "issues_by_title_list"
    template_name = "comics2/issues_by_title.html",

    def get_queryset(self):
        title = get_object_or_404(Title, title__iexact=self.args[0])
        return Issue.objects.filter(title=title)

Any ideas? And can someone please reply in baby-language, as I am new to Django and Python, so simply telling me to look at the Tutorial again isn’t going to help. So, maybe writing out the code would help! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T14:00:01+00:00Added an answer on May 21, 2026 at 2:00 pm

    Generally, your IssueByTitleView is the right way to do it. But as you use named groups in your URL regex (the (?P<title_slug>[-\w]+) part of your URL), you have to access the URL parameters through self.kwargs instead of self.args. Also, you have to filter on the slug field, not the title field:

    title = get_object_or_404(Title, slug=self.kwargs['title_slug'])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know, this might be a very basic question but I am not 100%
I know this is a very basic question - but I did not face
I know this is a very basic question. But I am really not able
I know this maybe a very basic question but I'm having a bit of
guys I know this question is very basic but I've met in few publications
Ok, I know this is a very basic question, but my head is swimming
I know this is very basic, but after massive refactoring, i remain a bit
I know this is a very basic question but when I compile my c/c++
This question seems to be very basic, but I don't know why, there is
I know this is very basic question, but I need to know, how I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.