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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:52:35+00:00 2026-05-20T04:52:35+00:00

I’m trying to replace the default ManyToManyField widget in the Admin to use a

  • 0

I’m trying to replace the default ManyToManyField widget in the Admin to use a FilteredSelectMultiple, and I’m having some issues. My error is Caught TypeError while rendering: unpack non-sequence

Here is my model

class Car(models.Model):
    parts = models.ManyToManyField('Part')

class Part(models.Model):
    name = models.CharField(max_length=64)

And this is my ModelAdmin

class CarAdmin(admin.ModelAdmin):
    form = myforms.CustomCarForm

And this is CustomCarForm

 class CustomCarForm(forms.ModelForm):
     def __init__(self, *args, **kwargs):
         super(CustomCarForm, self).__init__(*args, **kwargs)
         parts = tuple(Part.objects.all())
         self.fields['parts'].widget = admin.widgets.FilteredSelectMultiple(
             'Parts', False, choices=parts
         )

I receive this error when I try to view the Admin form

Request Method:     GET
Request URL:        http://127.0.0.1:8000/admin/foo/car/1/
Django Version:     1.2.5
Exception Type:     TemplateSyntaxError
Exception Value:    Caught TypeError while rendering: unpack non-sequence
Exception Location: /usr/lib/python2.4/site-packages/Django-1.2.5-py2.4.egg/django/forms/widgets.py in render_options, line 464
Python Executable:  /usr/bin/python
Python Version:     2.4.3

This error occurs if I use any of these to set parts

parts = Part.objects.all()
parts = list(Part.objects.all())
parts = tuple(Part.objects.all())

If I do this

parts = Part.objects.value_list('name')

I get Caught ValueError while rendering: need more than 1 value to unpack

Edit: If I take out choices=parts it renders fine, but the selection boxes are blank, and I need to have something in them.

  • 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-20T04:52:35+00:00Added an answer on May 20, 2026 at 4:52 am
            for option_value, option_label in chain(self.choices, choices):
    

    Apparently, choices is a list of tuples, first value being option_value and the second is option_label.

    I’m not sure what the first needs to be, but I’m guessing pk.

    Try:

    parts = [(x.pk, x.name) for x in Part.objects.all()]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6

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.