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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:33:39+00:00 2026-05-29T06:33:39+00:00

i got a problem with getting ManyToMany field values in template, here is the

  • 0

i got a problem with getting ManyToMany field values in template, here is the code:

models.py

class Client(models.Model):
name = models.CharField(max_length=18,help_text='Nazwa firmy klienta, musi być unikalna', verbose_name='Klienci')
slug = models.SlugField(max_length=255,help_text="Wartość sugerowana automatycznie na podstawie nazwy", unique=True, verbose_name='Odnośnik')
iconwhite =  models.ImageField(upload_to='iconswhite', verbose_name='ikona na białym tle', blank=True)
class Meta:
    ordering = ['name']
    verbose_name = "Klient"
def __str__(self):
    return self.name
def __unicode__(self):
    return self.name
def get_absolute_url(self):
    return '/clients/%s/' % self.slug

models.py

class Projects(models.Model):
def get_picture_path(instance, filename):
    return os.path.join('picture', str(instance.id), filename)
client = models.ManyToManyField(Client, verbose_name='Klient')
title = models.CharField(max_length=255, verbose_name='Tytuł projektu')
slug = models.SlugField(max_length=255, unique=True, verbose_name='Odnośnik')
status = models.CharField(max_length=1, choices=STATUS_CHOICES, default='d')
picture = models.ImageField(upload_to=get_picture_path, blank=True, null=True, help_text='Miniatura widoczna na str głównej oraz w galerii projektow')
class Meta:
    verbose_name = "Projekt"
def __str__(self):
    return self.title
def __unicode__(self):
    return self.title
def get_absolute_url(self):
    return '/projects/' + self.slug + '/' 

index.html

<div class="grid_4">
    <div class="container_img">
        <div><a href="/projects/{{ i.slug }}/"><img src="site_media/media/{{i.picture}}" /></a></div>
        <div class="client_icon">
        {% for client in projects.client.all %}
        <img src="site_media/media/{{client.iconwhite}}" />
        {% endfor %}
        </div>
    </div>
    <div class="project_description">
        <a href="/projects/{{ i.slug }}/"><p class="projects_title">{{ i.title }}</p></a>
        <p class="projects_description">{{ i.description|safe|removetags:"p br div"|truncatewords:9 }} <a href="/projects/{{ i.slug }}/"><span>see more »</span></a></p>
    </div>
</div>

I checked other similar topics, dunno what am i missing here 🙁

  • 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-29T06:33:40+00:00Added an answer on May 29, 2026 at 6:33 am

    If i is the variable holding an individual project (judging by the context in your HTML), you’d need:

    {% for client in i.client.all %}
        {{ client }}
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got another problem in the same code... I'm getting this error: initialization method
i got problem with my code and hopefully someone able to figure it out.
I have got one problem with the UITableViewController... The viewWillAppear method is not getting
I've got a problem with the formatting of inline code blocks within the VS2010
Anyone got a problem with php 5.2.12 getting a lot of Maximum execution time
I've got an problem with getting information back from a memory block allocated by
I have problem in getting wrong values in array of double. Instead of getting
I have got a Client/Server Application that using Asynchronous Socket.My problem is i cant
I've got a problem with getting a ComboBox to operate as expected when data
Got a problem that I'm having a hard time getting started on. Not a

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.