Comments (19)
There is nowhere near enough information in this report for me to tell you
anything useful. *How* are you trying to use it with Flask? *What* error are
you getting? Unless you show me some code I can't help you at all.
Original comment by [email protected]
on 14 Dec 2013 at 11:42
from prettytable.
The module is just returning a string without any form of formatting
Original comment by pilotkid2011
on 14 Dec 2013 at 11:44
from prettytable.
How are you using it? Show me code.
Original comment by [email protected]
on 14 Dec 2013 at 11:53
from prettytable.
def hello_admins(username):
from prettytable import *
x = PrettyTable(["Name","Phone","Yardage"])
x.add_row(['John',"7193382296","27"])
x.add_row(['Phil',"7195926682","16"])
x.get_string(attributes = {"class": "foo"})
return render_template("allshooters.html",tbl=x )
Original comment by pilotkid2011
on 14 Dec 2013 at 11:56
from prettytable.
Try replacing "get_string" with "get_html_string" and see if that works.
Original comment by [email protected]
on 14 Dec 2013 at 11:58
from prettytable.
[deleted comment]
from prettytable.
I get the same string result... :/
My html code is
{% block contents %}
<p>a</p>
{% for message in get_flashed_messages() %}
<div class = flash>
{{message}}
</div>
{% endfor %}
{{tbl}}
{% endblock %}
Original comment by pilotkid2011
on 15 Dec 2013 at 12:02
from prettytable.
Oh! That's because you're just passing the PrettyTable object x to the Flask
rendering system. You need to actually pass the string containing the HTML
code that PrettyTable generates. Get rid of the line:
x.get_string(attributes = {"class": "foo"})
and change the final line to:
return render_template("allshooters.html",tbl=x.get_html_string(attributes =
{"class": "foo"}))
(or, alternatively, store the output of get_html_string in an intermediary
variable and pass that to render_template).
Original comment by [email protected]
on 15 Dec 2013 at 12:03
from prettytable.
Yay it somewhat worked now I am getting the result as actual html" <table
class="foo"> <tr> <th>Name</th> <th>Phone</th> <th>Yardage</th> </tr> <tr>
<td>John</td> <td>7193382296</td> <td>27</td> </tr> <tr> <td>Phil</td>
<td>7195926682</td> <td>16</td> </tr> </table>" but i can figure it out..
unless you have any quick reconmendations
Original comment by pilotkid2011
on 15 Dec 2013 at 12:06
from prettytable.
This is probably something to do with Flask, automatically escaping HTML input
to templates in order to avoid CSS attacks and similar things. I vaguely
recall having to deal with something like that in the past, but I don't know
how to fix it off the top of my head. You should be able to find something in
the Flask docs easily enough.
Original comment by [email protected]
on 15 Dec 2013 at 12:08
from prettytable.
Ok also may I give you a small piece of constructive criticism with your
tutorial?
Original comment by pilotkid2011
on 15 Dec 2013 at 12:15
from prettytable.
Yes, of course! Please do.
Original comment by [email protected]
on 15 Dec 2013 at 1:32
from prettytable.
There were times when I was reading the tutorial where I was confused on what
you meant I also thought there could be more code but other than that I love
this module I've used it on 3 other projects (I am making my first site now)
but it is a great module it just needs a more coded and better worded tutorial
just to help others
Original comment by pilotkid2011
on 15 Dec 2013 at 4:17
from prettytable.
Also I am sorry about this but I cannot figure out the getting the table to
work without getting rid of the style sheet
Original comment by pilotkid2011
on 15 Dec 2013 at 4:27
from prettytable.
Try replacing "{{tbl}}" in your template with "{{tbl|safe}}" and see if that
fixes it.
Original comment by [email protected]
on 15 Dec 2013 at 4:47
from prettytable.
I LOVE YOU!!!!!!
Original comment by pilotkid2011
on 15 Dec 2013 at 4:49
from prettytable.
Glad it worked. You should make sure you understand why Flask automatically
escapes HTML by default, and understand when it is and isn't safe to use the
"safe" filter. Maybe read https://en.wikipedia.org/wiki/Cross-site_scripting.
Thanks for your feedback on the tutorial. Next time I update it I'll try
adding some more example code.
Original comment by [email protected]
on 15 Dec 2013 at 5:38
from prettytable.
Thank you I am am kinda learning the whole flask this but my site is pretty
cool
Original comment by pilotkid2011
on 15 Dec 2013 at 5:39
from prettytable.
Original comment by [email protected]
on 15 Dec 2013 at 5:56
- Changed state: Done
from prettytable.
Related Issues (20)
- how to display "ambiguous" width in chinese character?
- table.min_width is broken when using PLAIN_COLUMNS style HOT 2
- Field alignment error when using "blessings" module HOT 1
- Adding colors to column values messes up the spacing HOT 2
- Setting float_format in **kwargs does not actually affect output - confusing behavior HOT 1
- Permissions are incorrect HOT 1
- Add date formatting for datetime etc instances HOT 3
- In get_string, end is eval before sortby
- HTML output is lacking borders, alignment
- Cannot print unicode characters, for example: degree symbol °
- Pandas DataFrame Table Factory HOT 3
- Upload new version to pypi
- xterm reset escape sequence not filtered HOT 2
- Support large tables in output HOT 1
- Prettytable 0.7.2 does not handle rowspan correctly
- Creating a PrettyTable inside a for. HOT 1
- Project Future and Plans HOT 4
- Export project to Github (or other git hosting project) HOT 2
- Stretching columns when the data are longer than the header
- Options not actually used in formatting rows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettytable.