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 6331163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:00:36+00:00 2026-05-24T18:00:36+00:00

I have my models: class Volume(models.Model): volnumber = models.IntegerField(‘Volume Number’, primary_key=True) year = models.TextField()

  • 0

I have my models:

class Volume(models.Model):
    volnumber = models.IntegerField('Volume Number', primary_key=True) 
    year = models.TextField()
    #...#

class Article(models.Model):
    volnumber = models.ForeignKey(Volume)
    title = models.TextField(blank=True)
    slug = models.SlugField(max_length=100, db_index=True)
    #...#

my view:

# Article detail
def article_detail(request, slug):
return render_to_response('article_detail.html', {
    'article': get_object_or_404(Article, slug=slug),
})

my template:

{{ article.volume.year }}. <strong class="title">{{ article.title }}</strong>.Journal Vol.{{ article.volnumber }}

The problem is I am not getting any output for the year (title and volnumber are fine). The syntax seems correct..what am I doing wrong?

  • 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-24T18:00:37+00:00Added an answer on May 24, 2026 at 6:00 pm

    Try:

    {{ article.volnumber.year }}
    

    Since you’re simply following the relationship forward, article.volnumber should give you a reference to the associated Volume object.

    You’re not seeing anything in your template because article does not have a volume attribute. The templating engine fails silently and nothing is printed.


    Better yet, to make the references more intuitive you might want to consider renaming the attribute in your Article model from volnumber to simply volume.

    class Article(models.Model):
        volume = models.ForeignKey(Volume)
        # ...
    

    Using article.volume.year and article.volume.volnumber is, in my opinion, a lot more readable than article.volnumber.volnumber.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this models: class BillHeader(models.Model): billno = models.IntegerField(primary_key=True, blank=True) class BillData(models.Model): price =
I have two models: class Actor(models.Model): name = models.CharField(max_length=30, unique = True) event =
I have two models: class Studio(models.Model): name = models.CharField(Studio, max_length=30, unique=True) class Film(models.Model): studio
You have models: class Order(Model): date = DateField(editable = False, auto_now_add=True) status = CharField(max_length
I have these models: class Projects(models.Model): projectName =models.CharField(max_length = 100,unique=True,db_index=True) projectManager = EmbeddedModelField('Users') class
I have following models class Artist(models.Model): name = models.CharField(max_length=200, unique=True) photo = models.CharField(max_length=250) views
I have theses models: class Year(models.Model): name = models.CharField(max_length=15) date = models.DateField() class Period(models.Model):
I have two models class Employer(models.Model): name = models.CharField(max_length=300, blank=False) id = models.IntegerField() status
I have two models for Publications and Employees: class Publication(models.Model): BOOK_CHAPTER = 1 ARTICLE
I have two models: class ModelOne(models.Model): something = models.TextField[...] class ModelTwo(models.Model): other_something = models.TextField[...]

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.