1đź‘Ť
âś…
()
is an empty tuple whereas []
represents an empty list.
Since global_settings.TEMPLATE_CONTEXT_PROCESSORS
is a list
type, you should only concatenate that to another list:
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + []
👤Ozgur Vatansever
1đź‘Ť
Example 1
>>> type(())
<type 'tuple'>
Example 2
>>> [1,2,3] + ()
TypeError: can only concatenate list (not "tuple") to list
On the last line of your example code, you’re adding ()
, which is , by the first example 1, the literal for an empty tuple. By your error and example 2, i can assume that global_settings.TEMPLATE_CONTEXT_PROCESSORS
is a list, and you are trying to “list + tuple”, which is incompatible to __add__
and raises that exception.
Try changing the last line to:
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS
or, if by some unknown reason, you really need to add something…
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + []
👤Diogo Martins
- [Answered ]-Error from installing Django using pip on mac
- [Answered ]-Django URL to View mapping
- [Answered ]-How to define Django settings without default DB settings?
- [Answered ]-Annotate causes ProgrammingError: must appear in the GROUP BY clause or be used in an aggregate function
- [Answered ]-Passing kwargs into get_or_create method in Django
Source:stackexchange.com