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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:14:51+00:00 2026-05-30T11:14:51+00:00

I have these models: class Supplier(models.Model): name = models.CharField(max_length=50) def __unicode__(self): return u"%s" %

  • 0

I have these models:

class Supplier(models.Model):
    name = models.CharField(max_length=50)
    
    def __unicode__(self):
        return u"%s" % self.name

class SupplierOrder(models.Model):
    supplier = models.ForeignKey(Supplier)
    numero_invoice = models.CharField(max_length=50)

I have this form:

class SupplierOrderForm(forms.ModelForm):
    class Meta:
        model = SupplierOrder

In pass a supplier order form to a template in which I have this code:

<table>
{% for f in forms %}
    {% for field in f.visible_fields %}
        <tr>
            <td>{{ field.label_tag }}</td>
            <td>{{ field.value }}</td>
        </tr>
    {% endfor %}
{% endfor %}

The problem is that for supplier it display the supplier id, but I want the supplier name.

  • 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-30T11:14:52+00:00Added an answer on May 30, 2026 at 11:14 am

    This forloop’s field value is an instance of BoundField:

    {% for field in f.visible_fields %}
    

    You can get the value of a BoundField instance as such:

    boundfield.field.to_python(boundfield.value())
    

    So you could make a trivial template filter:

    from django import template
    
    register = template.Library()
    
    @register.filter
    def to_python(boundfield):
        return boundfield.field.to_python(boundfield.value())
    

    And use it in your template:

    {% load your_template_tags %}
    
    {% for field in form.visible_fields %} 
        <tr>
            <td>{{ field.label_tag }}</td>
            <td>{{ field|to_python }}</td>
        </tr>
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these models in Django: class Customer(models.Model): def __unicode__(self): return self.name name =
I have these Django models: class Group(models.Model): name = models.CharField(max_length=100) parent_group = models.ManyToManyField("self", blank=True)
I currently have these models: class Category(models.Model): name = models.CharField(max_length=200) parent = models.ForeignKey('self', blank=True,
I have these models: class App(models.Model): name = models.CharField(max_length=100) class ProjectA(models.Model): name = models.CharField(max_length=100)
I have these 3 models in models.py class Customer(models.Model): name = models.CharField(max_length=50) .... class
I have these models: class Person(models.Model): name=models.CharField(max_length=100) family=models.CharField(max_length=100) class MailContact(models.Model): person=models.ForeignKey(Person) email=models.CharField(max_length=100) #some fields
I have these models set up in Django: class SourceBusiness(models.Model): source = models.CharField(max_length=100) ...(other
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 these two models : class Module(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(unique=True,
I have (essentially) the following models: class foo(models.model): name = models.CharField(max_length=255) size = models.PositiveIntegerField()

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.