Reputation: 7466
I have a class defined like this:
class MyModel(models.Model):
...
I have an instance of this class and I would like to iterate over it's meta attributes:
opts = instance._meta
for f in opts.many_to_many + opts.concrete_fields + opts.virtual_fields:
...
This code works perfectly with Django 1.7, but doesn't work with Django 1.8.
The error I'm receiving is a type error and it's value is:
can only concatenate tuple (not "list") to tuple
What can be the problem with it?
Upvotes: 1
Views: 90
Reputation: 18070
The problem is in the opts.virtual_fields
type. It is list
now. I guess it was changed in 1.8
To solve it:
metas = opts.concrete_fields + opts.many_to_many + tuple(opts.virtual_fields)
Upvotes: 1