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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:16:29+00:00 2026-05-22T18:16:29+00:00

I have two related models: class Package(models.Model): package_name = models.CharField(max_length=64) ptype = models.CharField(max_length=16) class

  • 0

I have two related models:

class Package(models.Model):
    package_name = models.CharField(max_length=64)
    ptype = models.CharField(max_length=16)

class Extra(models.Model):
    package = models.ForeignKey(Package, related_name='package')
    data = models.DecimalField(max_digits=8, decimal_places=2, blank=True, null=True)
    information = models.CharField(max_length=1024, blank=True)

view.py:

def show_package(request):
    list = get_list_or_404(Package, ptype='sometype')
    return render(request, 'table.html', {'list': list})

and template:

{% for row in list %}
<table class="provider_list">
 <tr>
     <td>{{ row.package_name}}</td>
     <td>{{ row.ptype }}</td>
</tr>
</table>
{% endfor %}

How can I add an additional table (from Extra model) next to the prelated table?

Like:

<table>
{% for extra_row in extra_list %}
<tr>
    <td>{{ extra_row.data }}</td>
    <td>{{ extra_row.information }}</td>
</tr>
{% endfor %}
</table>

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-22T18:16:30+00:00Added an answer on May 22, 2026 at 6:16 pm

    try this:

    {% for package in list %}
        <table class="provider_list">
            <tr>
                 <td>{{ package.package_name}}</td>
                 <td>{{ package.ptype }}</td>
                 <td>
                    <!-- fetch the related data -->
                    <table>
                    {% for extra in package.extra_set.all %}
                        <tr>
                            <td>{{ extra.data }}</td>
                            <td>{{ extra.information }}</td>
                        </tr>
                    {% endfor %}
                    </table>
                 </td>
            </tr>
        </table>
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes, Portfolio, and PortfolioImage. class PortfolioImage(models.Model): portfolio = models.ForeignKey('Portfolio', related_name='images') ...
I have two models class Employer(models.Model): name = models.CharField(max_length=300, blank=False) id = models.IntegerField() status
I have two models: call them questions and answers: class FacetQuestion(models.Model): the_question = models.CharField(max_length=50)
Say I have two models, Article and Category: class Article(models.Model): category = models.ForeignKey(Category, related_name='articles')
I have two basic models, Story and Category: class Category(models.Model): title = models.CharField(max_length=50) slug
I have two models related one-to-many: a Post and a Comment : class Post(models.Model):
hi i have to following model class Match(models.Model): Team_one = models.ForeignKey('Team', related_name='Team_one') Team_two =
I have these two models: class CommonVehicle(models.Model): year = models.ForeignKey(Year) series = models.ForeignKey(Series) engine
I have the following two models class Author(Model): name = CharField() class Publication(Model): title
I have two models: class Foo(models.Model): foo_field = ... class Bar(models.Model): foo = models.ForeignKey(Foo,

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.