Exception Value: need more than 1 value to unpack #19

Closed
CombatCode opened this Issue May 3, 2011 · 6 comments

Projects

None yet

3 participants

@CombatCode
CombatCode commented May 3, 2011 edited

Hello, i have a some stange issue:

Django Version: 1.3
Exception Type: ValueError
Exception Value: need more than 1 value to unpack
Exception Location: /home/combatcode/www/somehere/smart_selects/db_fields.py in init, line 16
Python Executable: /usr/local/python2.6/bin/python
Python Version: 2.6.1

Model:

class Somemodel(models.Model):
    kategoriagl = models.ForeignKey('self')
    kategorianext = ChainedForeignKey(
        'self', 
        chained_field="kategoriagl",
        chained_model_field="kategoriagl", 
        show_all=False, 
        auto_choose=True
    )

app is installed, and imported to models. Can u tell me what is wrong?

Edit (by blag): Updated to use GFM.

@CombatCode CombatCode closed this May 3, 2011
@CombatCode CombatCode reopened this May 3, 2011
@blag
Collaborator
blag commented Oct 13, 2016

This is a bug - ChainedForeignKey expects a module string of the format ".".

The current workaround is to specify the target as a full string. Example:

class Somemodel(models.Model):
    kategoriagl = models.ForeignKey('self')
    kategorianext = ChainedForeignKey(
        'somemodule.Somemodel',  # <-- "module.Model"
        chained_field="kategoriagl",
        chained_model_field="kategoriagl", 
        show_all=False, 
        auto_choose=True
    )

You aren't the only person who reported this issue. I'll look into fixing it.

@SalahAdDin
Contributor

Interesting, please update the documentation.

@blag
Collaborator
blag commented Oct 18, 2016

I'd rather just fix the issue than update the documentation. I'll have time to do that later this week.

@blag
Collaborator
blag commented Oct 31, 2016

This was fixed in 15d3d6e and released to PyPI a few days ago. Please update to 1.2.6 (or later).

@SalahAdDin I don't think any additional documentation is required for this, since it's really just re-enabling built-in behavior of vanilla Django ForeignKey and ManyToManyField relations. But if you have any suggestions for additional documentation I'd be happy to work on that.

@blag blag closed this Oct 31, 2016
@SalahAdDin
Contributor

@blag Release it in pypi or here in github, in release section we can see until 1.2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment