-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: unsupported operand type(s) for +=: 'set' and 'tuple #803
Comments
This code could certainly be made more resilient by converting both sides of the addition into an expected format. Maybe one could use the undocumented |
Thank you for fielding this issue and for the suggestion. We were able to import Update: the below actually errors upon migrating, see #803 (comment) below for final solution
My guess was that converting to a |
django-mptt only recently started using Maybe that's the reason for this? |
That is likely since we had been using django-mptt version 0.8.6 up until now, which seems to date to @ 2016 |
It turns out the So we finally solved it by converting to a tuple in the migration file's functions, before mptt.register() runs.
Hope this helps anyone who might come up against this seemingly obscure issue. |
I'm not sure whether there's anything that could be done in django-mptt to help with this? |
We were originally monkey-patching dajngo-mptt's models.py to convert the reference to our app's index_together to a tuple to "normalize" it with django-mptt's index_together when it does the merging of the two with
(Line 377 dango-mptt models.py)
Would it work to make mptt's index_together be passed as a set rather than tuple? I admittedly do not know enough about how django-mptt (or mptt in general) works to know if this has potential to break something somewhere else or for somebody else. |
When upgrading from Django-mptt 0.8.6 to 0.11.0 or later version, Django migrations fail with unsupported type error:
TypeError: unsupported operand type(s) for +=: 'set' and 'tuple'
The error is traced to:
django-mptt/mptt/models.py
Line 377 in 7a6a54c
The code is expecting a tuple so when a set is passed, it throws this error. Is it possible to make the code more robust to handle both sets and tuples?
We came across this error when upgrading from Django 1.11 to 2.2.24 which required mptt upgrade from 0.86 to 0.11 due to template loader errors. This error did not occur before upgrading.
Failing migrations stack trace:
The text was updated successfully, but these errors were encountered: