Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#14077 closed (duplicate)

Need an easy way to display model instance field names and values in templates

Reported by: haroldb Owned by: nobody
Component: Forms Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Is it possible to write a helper that would take a bound ModelForm, and allow it to be displayed in a template something like:

<table>
    {% for field in fields %}
        <tr>
            <td>{{ field.name }}</td>
            <td>{{ field.value }}</td>
        </tr>
    {% endfor %}
</table>

It would only display those fields that should be displayed to users (e.g. ignore 'editable=False', etc).

This would make displaying models to users much simpler, since if the definition of the model changed, it wouldn't be necessary to update the template. It'd be great if this was a standard helper.

Thanks

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by haroldb

  • milestone set to 1.3
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 4 years ago by akaariai

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #10427

comment:3 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.