Skip to content

Instantly share code, notes, and snippets.

@jieter
Last active September 23, 2016 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jieter/1173ba26dfbd883a0eb1c44b516f155b to your computer and use it in GitHub Desktop.
Save jieter/1173ba26dfbd883a0eb1c44b516f155b to your computer and use it in GitHub Desktop.
# models.py
class NamedFloat(models.Model):
col1 = models.CharField(max_length=1, primary_key=True)
col2 = models.FloatField(blank=True, null=True)
# test:
@pytest.mark.django_db
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