Skip to content

Instantly share code, notes, and snippets.

Last active September 23, 2016 09:37
What would you like to do?
class NamedFloat(models.Model):
col1 = models.CharField(max_length=1, primary_key=True)
col2 = models.FloatField(blank=True, null=True)
# test:
def test_floatfield():
class Table(tables.Table):
class Meta:
model = NamedFloat
NamedFloat.objects.create(col1='a', col2=2.2)
NamedFloat.objects.create(col1='b', col2=6.0)
table = Table(NamedFloat.objects.all())
request = build_request('/')
RequestConfig(request, {'per_page': 2}).configure(table)
template = Template('{% load django_tables2 %}{% render_table table %}')
html = template.render(Context(dict(request=request, table=table)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment