datatables icon indicating copy to clipboard operation
datatables copied to clipboard

Flask-Alchemy

Open samuelmukoti opened this issue 10 years ago • 2 comments
trafficstars

Hi,

Thank you for this amazing module! It really does help as all the datatables examples that i've seen are PHP.

I've got a flask-alchemy project with flask-restless for REST API. Would you have an example or explanation of the lines:

@view_config(route_name="data", request_method="GET", renderer="json")
def users_data(request):

In the views.py sample file.

my views are more like

@app.route('/api/user', methods=['GET', 'POST'])
def users_data(request):

Thank you

samuelmukoti avatar May 19 '15 07:05 samuelmukoti

Hey there, thanks for the kind words :)

The example uses the Pyramid framework and you are using Flask, you can ignore them in the example (It's just boilerplate). The bit inside the function:

table = DataTable(request.GET, User, User.query, [
    "id",
    ("name", "full_name", lambda i: "User: {}".format(i.full_name)),
    ("address", "address.description"),
 ])
...

should still be the same.

orf avatar May 20 '15 12:05 orf

Hi, thank you for this module. That's so amazing! I have another question about sqlalchemy with flask, if i'm not using orm, how to change my code like

table = DataTable(request.GET, User, User.query, [
    "id",
    ("name", "full_name", lambda i: "User: {}".format(i.full_name)),
    ("address", "address.description"),
 ])
...

Thanks !

seanmars avatar May 16 '17 03:05 seanmars