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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:07:41+00:00 2026-05-22T16:07:41+00:00

I have a survey application that creates forms of dynamic size. I use the

  • 0

I have a survey application that creates forms of dynamic size. I use the formula “question_id_part” where question is fixed, id is the id of the question being asked, and part is one of three parts.

In my template, I need to be able to group these by a category, so I loop through the categories in the survey, get all the questions in that category, then I have a template tag to get my form field.

{% load my_tags %}
...
{% for category in survey.category_set.all %}
    <h3>{{category}}</h3>
    {% for question in category.factor_set.all %}
        {% get_field_for_question_part question.id form "type" %} 
    {% endfor %}
{% endfor %}
...

Then I have a corresponding template tag that looks like this:

@register.simple_tag
def get_field_for_question_part(question_id, form, part):
    field_name = "question_%s_%s" % (question_id, part)
    field = form.fields[field_name]
    return BoundField(form, field, field_name)

My question is this:
By explicitly importing BoundField my template tag knows too much about how forms work internally and thus is brittle to future changes in the non-public behavior of forms. Thus, it seems to me that the BoundField should be accessible somehow as a method on field — but for the life of me I can’t figure out what that method would be. Am I missing something obvious?

  • 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-22T16:07:42+00:00Added an answer on May 22, 2026 at 4:07 pm

    Try:

    @register.simple_tag
    def get_field_for_question_part(question_id, form, part):
        field_name = "question_%s_%s" % (question_id, part)
        return form.__getitem__(field_name)
    

    See method definition on line 101 here: django/forms/forms.py

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET 4.0 application that handles survey responses. I want to dynamically
I am writing a survey application, and I have a form that can have
We have a web application that saves survey data in XML format, rather than
I have a survey application, where users can create surveys and give choices for
So I have this survey that I am pulling results from and I have
I have an application that I know would make a great cube and would
I am working on a survey application. I have a sql server database holding
I have an asp.net web forms application. In this application, students upload assignments and
So I have a simple application as in RailsCast about nested forms. and a
I have a fairly simple Rails application that allows users to manage their clients

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.