#ValueError: too many values to unpack (expected 2)

16 messages · Page 1 of 1 (latest)

viral trout
#

Full Error: File "/home/nursmozs/virtualenv/PetersNurseprofessorsProject-master/3.8/lib/python3.8/site-packages/django/forms/widgets.py", line 691, in _choice_has_empty_value
value, _ = choice
ValueError: too many values to unpack (expected 2)

I hosted my website on namecheap. This error occurs after i login which is supposed to direct me to a given form after successful login. I had followed some guides from the internet and it did not help me. Any help will be appreciated. Here is the website, someone can click on order now to see the error https://nurseprofessors.com/

dark cloak
#

you probably have a CharField(choices=CHOICES) somewhere where CHOICES contains an item that doesn't have exactly two values as it should, maybe check that

viral trout
dark cloak
#

different python versions, django versions maybe?

viral trout
dark cloak
#

try to reproduce the namecheap setup on your local machine then, then you can likely debug the actual problem locally

#

or if they allow a direct ssh connection try to debug it on the server within a Django shell

viral trout
#

In namecheap, i use python 3.8. Is there a way to run python 3.8? My system uses python 3.12

#

I was thinking of using docker

gritty epoch
#

You can also create a venv or pyenv or some other virtual environment isolated to a certain path and install the version of python needed for that virtual environment, as well as the packages / versions from the requirements.txt.

dark cloak
#

you don't just want to replace the system python version. I naively did that on Ubuntu a few years ago and bricked my entire machine 😬

#

I'd first try to figure out if this is the problem at all though. maybe try docker or a virtual machine locally to debug your current problem before changing your production system

viral trout
#

I solved the problem. It was a very simple one. I did not use brackets in my dictionary.

#

NUMBER_OF_PAGES_CHOICES = [
('Double Spaced', 'Double Spaced'),
('Single Spaced', 'Single Spaced'),
]

#

I just wrote it as:

NUMBER_OF_PAGES_CHOICES = [
'Double Spaced', 'Double Spaced',
'Single Spaced', 'Single Spaced',
]