ValueError at /plyn Expected table or queryset, not 'str'.
Request Method:GETRequest URL:http://127.0.0.1:8000/plynDjango Version:1.5Exception Type:ValueErrorException Value: Expected table or queryset, not 'str'. Exception Location:/usr/lib/python2.7/site-packages/django_tables2-0.13.0-py2.7.egg/django_tables2/templatetags/django_tables2.py in render, line 176Python Executable:/usr/bin/pythonPython Version:2.7.3Python Path: ['/home/tpelka/workspace/energie/wsgi/energie', '/usr/lib/python2.7/site-packages/ropevim-0.4-py2.7.egg', '/usr/lib/python2.7/site-packages/ropemode-0.2-py2.7.egg', '/usr/lib/python2.7/site-packages/rope-0.9.4-py2.7.egg', '/usr/lib/python2.7/site-packages/mozmill-1.5.20-py2.7.egg', '/usr/lib/python2.7/site-packages/ManifestDestiny-0.2.2-py2.7.egg', '/usr/lib/python2.7/site-packages/mozrunner-2.5.14-py2.7.egg', '/usr/lib/python2.7/site-packages/jsbridge-2.4.16-py2.7.egg', '/usr/lib/python2.7/site-packages/virtualenv-1.9.1-py2.7.egg', '/usr/lib/python2.7/site-packages/django_tables2-0.13.0-py2.7.egg', '/usr/share/qa-tools/python-modules', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gst-0.10', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info'] Server time:út, 9 Dub 2013 20:55:56 +0200 Any clue why this error happen. Sources attached. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.{% extends "base.html" %} {% block title %} Energie - plyn {% endblock %} {% load render_table from django_tables2 %} {% block content %}
{% render_table table %}
{% endblock %}
Title: {% block title %}Energie{% endblock %}
Vítej, {{ user }}.
Změnint heslo / Odhlásit se
{% block content %}{% endblock %}
# -*- coding: utf-8 -*- import django_tables2 as tables from energie.models import Record class RecordTable(tables.Table): date = tables.Column() class Meta: model = Record # add class="paleblue" to <table> tag #attrs = {"class": "paleblue"}
# -*- coding: utf-8 -*- from django.db import models from django.contrib import admin class Record(models.Model): date = models.DateField('?as zad?n?') water = models.ForeignKey('Water', verbose_name='Voda') gas = models.ForeignKey('Gas', verbose_name='Plyn') el = models.ForeignKey('El', verbose_name='Elekt?ina') note = models.TextField('Pozn?mka', blank=True) def __unicode__(self): return unicode(self.date) class Meta: ordering = ['date'] verbose_name = 'z?znam' verbose_name_plural = 'z?znamy' class RecordAdmin(admin.ModelAdmin): list_display = ('date', 'water', 'gas', 'el', 'note') search_fields = ['date'] date_hierarchy = 'date' class Water(models.Model): water = models.DecimalField('Stav vody', max_digits=5, decimal_places=1) water_delta = models.DecimalField('Spot?eba vody', max_digits=4, decimal_places=1, default=1) def __unicode__(self): return unicode(self.water) class Meta: verbose_name = 'voda' verbose_name_plural = 'voda' class WaterAdmin(admin.ModelAdmin): list_display = ('water', 'water_delta') class Gas(models.Model): gas = models.DecimalField('Stav plynu', max_digits=8, decimal_places=1) gas_delta = models.DecimalField('Spot?eba plynu', max_digits=4, decimal_places=1, default=1) def __unicode__(self): return unicode(self.gas) class Meta: verbose_name = 'plyn' verbose_name_plural = 'plyn' class GasAdmin(admin.ModelAdmin): list_display = ('gas', 'gas_delta') class El(models.Model): el1 = models.DecimalField('Stav elekt?iny', max_digits=8, decimal_places=1) el1_delta = models.DecimalField('Spot?eba elekt?iny', max_digits=4, decimal_places=1, default=1) el2 = models.DecimalField('Stav elekt?iny (no?n? proud)', max_digits=8, decimal_places=1) el2_delta = models.DecimalField('Spot?eba elekt?iny (no?n? proud)', max_digits=4, decimal_places=1, default=1) def __unicode__(self): return unicode(self.el1) class Meta: verbose_name = 'elekt?ina' verbose_name_plural = 'elekt?ina' class ElAdmin(admin.ModelAdmin): list_display = ('el1', 'el1_delta', 'el2', 'el2_delta') admin.site.register(Record, RecordAdmin) admin.site.register(Water, WaterAdmin) admin.site.register(Gas, GasAdmin) admin.site.register(El, ElAdmin)
# -*- coding: utf-8 -*- import os from django.shortcuts import render_to_response, render from django_tables2 import RequestConfig from django.template import RequestContext from energie.models import Record from energie.tables import RecordTable def home(request): return render_to_response('home.html', {}, context_instance=RequestContext(request)) def plyn(request): table = RecordTable(Record.objects.all()) RequestConfig(request).configure(table) return render(request, 'plyn.html', {'table': table}) # return render_to_response('plyn.html', {"records": table,}, context_instance=RequestContext(request))