Fix #178 -- using unicode in `fields` option.
This commit is contained in:
parent
20b433d494
commit
2bf273a350
|
@ -176,13 +176,13 @@ class DeclarativeColumnsMetaclass(type):
|
|||
if opts.fields:
|
||||
# Each item in opts.fields is the name of a model field or a
|
||||
# normal attribute on the model
|
||||
for name in opts.fields:
|
||||
for field_name in opts.fields:
|
||||
try:
|
||||
field = opts.model._meta.get_field(name)
|
||||
field = opts.model._meta.get_field(field_name)
|
||||
except FieldDoesNotExist:
|
||||
extra[name] = columns.Column()
|
||||
extra[field_name] = columns.Column()
|
||||
else:
|
||||
extra[name] = columns.library.column_for_field(field)
|
||||
extra[field_name] = columns.library.column_for_field(field)
|
||||
|
||||
else:
|
||||
for field in opts.model._meta.fields:
|
||||
|
|
|
@ -294,3 +294,16 @@ def doesnotexist_from_accessor_should_use_default():
|
|||
table = Table(Person.objects.all())
|
||||
assert table.rows[0]["first_name"] == "Brad"
|
||||
assert table.rows[0]["region"] == "abc"
|
||||
|
||||
|
||||
@models.test
|
||||
def unicode_field_names():
|
||||
class Table(tables.Table):
|
||||
class Meta:
|
||||
model = Person
|
||||
fields = (six.text_type("first_name"),)
|
||||
|
||||
Person.objects.create(first_name="Brad")
|
||||
|
||||
table = Table(Person.objects.all())
|
||||
assert table.rows[0]["first_name"] == "Brad"
|
||||
|
|
Loading…
Reference in New Issue