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

  • Home
  • SEARCH
  • 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 8732709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:29:11+00:00 2026-06-13T09:29:11+00:00

I’m using Django 1.4 with Python 2.7 on Ubuntu 12.04. I’m going to continue

  • 0

I’m using Django 1.4 with Python 2.7 on Ubuntu 12.04.

I’m going to continue to update this question as I make progress.

UPDATE 2:

I’m trying to generate 2 choice fields in a form using information from an existing model.

class AssignProject(forms.Form):

    def __init__(self, devs, *args, **kwargs):
        """
        ..  method:: __init__()

            Class constructor

            :param devs: Tuple with which developer
        """
        super(AssignProject, self).__init__(*args, **kwargs)
        self.dev = forms.ChoiceField(widget = forms.Select(), choices = devs, required = True)
        self.designer = forms.ChoiceField(widget = forms.Select(), choices = devs, required = True)

At this point I can’t seem to access dev and designer ChoiceField in my template yet.

Here is the view:

@login_required
def view_all_projects(request):
    """
    ..  function:: view_projects()

        Show the projects

        :param request: Django Request object
    """
    data = { 'user' : request.user }
    if (request.user.is_authenticated() and request.user.is_superuser):
        all_projects = Projects.objects.filter(active = True)
        dev_info = User.objects.filter(is_staff = True, is_superuser = False)

        dev_dict = {}
        for dev in dev_info:
            dev_dict[dev.id] = '{0} {1}'.format(dev.first_name, dev.last_name)

        devs = tuple(dev_dict.items())

        form = AssignProject(devs)
        data.update({ 'form' : form })
        data.update({ 'projects'  : all_projects })
        data.update(csrf(request))
        return render_to_response("view_all_projects.html", data)

    return render_to_response("index.html", data)

I have verified that the developers/designers are properly getting set in the devs tuple.

…and the template from view_all_projects.html:

<form action="/assignProject/" method="post">{% csrf_token %}
    <table>
        <td>
            <input type="hidden" name="project_id" value={{ project.id }}>
            <tr>
                <td align="right"><label class="formlabel">Assign Developer:<br /></label></td><td>{{ form.dev }}</td>
            </tr>
            <tr>
                <td align="right"><label class="formlabel">Assign Designer:<br /></label></td><td>{{ form.designer }}</td>
            </tr>
                <tr>
                    <td align="right"><label class="formlabel">&nbsp;</label></td><td><input type="submit" value="Submit  &#9658;"></td>
                </tr>
        </td>    
    </table>
</form> 

I don’t see any errors, but I do see a strange object reference in place of the ChoiceField in the template.

<django.forms.fields.ChoiceField object at 0x7ffdbc054190>
<django.forms.fields.ChoiceField object at 0x7ffdbc0542d0>

I see these instead. I know I’m close…just can’t quite get what I’m going wrong.

Thoughts?

  • 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-13T09:29:12+00:00Added an answer on June 13, 2026 at 9:29 am

    The issue was entirely in the form __init__.

    I should have assigned the fields like follows:

    class AssignProject(forms.Form):
    
        def __init__(self, devs, *args, **kwargs):
            """
            ..  method:: __init__()
    
                Class constructor
    
                :param devs: Tuple with developers
            """
            super(AssignProject, self).__init__(*args, **kwargs)
            self.fields['dev'] = forms.ChoiceField(widget = forms.Select(), choices = devs, required = True)
            self.fields['designer'] = forms.ChoiceField(widget = forms.Select(), choices = devs, required = True)
    

    Note the self.fields['dev'] not self.dev. Fixed everything.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

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.