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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:26:04+00:00 2026-06-09T20:26:04+00:00

I have 2 models in my Django app that have a many-to-many relationship. How

  • 0

I have 2 models in my Django app that have a many-to-many relationship. How do I display each of the categories that a product will have? What do I include in the view and template?

class Product(models.Model):
    website = models.CharField('Product name', max_length = 200)
    mutliple_cat = models.ManyToManyField(Multicat, null=True, blank=True)
    def __unicode__(self):
        return self.website

class Multicat(models.Model):
    mutlicat = models.CharField('Multi cat', max_length = 200, null=True, blank=True)
    mutlicat_url = models.CharField('Multi cat url', max_length = 200, null=True, blank=True)
    def __unicode__(self):
        return unicode(self.mutlicat)

This is what I have in my view:

product = Product.objects.order_by("website")

Template:

{% for prod in product %}
    {% for cat in prod.multiple_cat.all %}
            {{ cat.multicat }}
    {% endfor %}
{% endfor %} 
  • 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-06-09T20:26:06+00:00Added an answer on June 9, 2026 at 8:26 pm

    Assuming you’re passing a Product in a variable named my_product to the template:

    {% for cat in my_product.multiple_cat.all %}
        multicat name: {{ cat.multicat }}
        multicat url: {{ cat.multicat_url }}
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Django app, I have a page.html that includes forms from multiple models
I have a django app that suppose to display invoices and clients. Now for
I have the following models in my Django app. How can I from the
I have a django app with models as follows: A Question model An Answer
I have a simple test case failing in Django: Model (app/models.py): from django.db import
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
I have the following Django models: Bar, Bistro and Restaurant Each of the above
I have a Django app that allows the user to create variables and name
I have a simple django app that is using only the admin. This is
I have a django app that stores email threads. When I parse the original

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.