ich hätte da mal wieder ne Frage, verstehe die Funktion LinkCol nicht, bzw. irgendwie bekomme ich sie nicht zum Laufen und weiß nicht wo der Fehler liegt.
Hier mal die 'Doku':
https://github.com/plumdog/flask_table/ ... columns.py
Code"""
Format the content as a link. Requires a endpoint to use to find
the url and can also take a dict of url_kwargs which is expected
to have values that are strings which are used to get data from
the item.
Eg:
view = LinkCol('View', 'view_fn', url_kwargs=dict(id='id'))
This will create a link to the address given by url_for('view_fn',
id=item.id) for each item in the iterable.
"""
Code: Alles auswählen
[...]
from flask_table import Table, Col, LinkCol
class ItemTable(Table):
url = 'www.linktest.de?='
classes = ['table table-bordered', 'border="2"']
title = LinkCol('title', url, url_kwargs=dict(id='video_hash'))
genre = Col('genre')
is_playlist = Col('playlist')
playtime = Col('playtime')
comment = Col('comment')
class Item(object):
def __init__(self, title, genre, is_playlist, playtime, comment):
self.title = title
self.genre = genre
self.is_playlist = is_playlist
self.playtime = playtime
self.comment = comment
@app.route('/info')
def info():
items = video.query.all()
table = ItemTable(items)
return render_template('info.html', table=table, title='debug info')
[...]
Es funktioniert auch alles, also zumindest wenn ich normale Col's mache, bekomme mein Tabele, alles hübsch.
Nur die Sache mit dem das ganze als link zu bekommen klappt halt nicht und ich weiß nicht warum
Achja hier nochmal meine model.py
Code: Alles auswählen
from app import db
from app import app
class video(db.Model):
__tablename__ = 'video'
video_id = db.Column(db.Integer, unique=True, primary_key=True)
video_hash = db.Column(db.String(128), nullable=False)
title = db.Column(db.String(128))
genre = db.Column(db.String(128))
is_playlist = db.Column(db.String(2))
playtime = db.Column(db.String(10))
rateing = db.Column(db.String(5))
comment = db.Column(db.String(254))
added_by = db.Column(db.String(128))
create_data = db.Column(db.DateTime)
Kann mir Jemand helfen hier etwas Licht ins Dunkel zu bringen wo es jetzt eigentlich harkt?127.0.0.1 - - [11/Mar/2015 14:49:29] "GET /info HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/app/view.py", line 175, in info
return render_template('info.html', table=table, title='debug info')
File "/usr/lib64/python2.7/site-packages/flask/templating.py", line 128, in render_template
context, ctx.app)
File "/usr/lib64/python2.7/site-packages/flask/templating.py", line 110, in _render
rv = template.render(context)
File "/usr/lib64/python2.7/site-packages/jinja2/environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib64/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "/app/templates/info.html", line 1, in top-level template code
{% extends "layout.html" %}
File "/app/templates/layout.html", line 80, in top-level template code
{% block content %}
File "/app/templates/info.html", line 5, in block "content"
{{table}}
File "/usr/lib64/python2.7/site-packages/flask_table/table.py", line 60, in __html__
tbody = self.tbody()
File "/usr/lib64/python2.7/site-packages/flask_table/table.py", line 75, in tbody
out = [self.tr(item) for item in self.items]
File "/usr/lib64/python2.7/site-packages/flask_table/table.py", line 92, in tr
''.join(c.td(item, attr) for attr, c in self._cols.items()
File "/usr/lib64/python2.7/site-packages/flask_table/table.py", line 93, in <genexpr>
if c.show))
File "/usr/lib64/python2.7/site-packages/flask_table/columns.py", line 85, in td
self.td_contents(item, self.get_attr_list(attr)))
File "/usr/lib64/python2.7/site-packages/flask_table/columns.py", line 226, in td_contents
url=self.url(item),
File "/usr/lib64/python2.7/site-packages/flask_table/columns.py", line 222, in url
return url_for(self.endpoint, **self.url_kwargs(item))
File "/usr/lib64/python2.7/site-packages/flask/helpers.py", line 312, in url_for
return appctx.app.handle_url_build_error(error, endpoint, values)
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1641, in handle_url_build_error
reraise(exc_type, exc_value, tb)
File "/usr/lib64/python2.7/site-packages/flask/helpers.py", line 305, in url_for
force_external=external)
File "/usr/lib64/python2.7/site-packages/werkzeug/routing.py", line 1649, in build
raise BuildError(endpoint, values, method)
BuildError: ('www.linktest.de?=', MultiDict([('id', u'NoI0vOdoNuo11')]), None)