djangosnippets.org: Latest snippets tagged with 'table'https://djangosnippets.org/tags/table/2016-01-06T19:37:09.149179-06:00delete object from table in form
2016-01-06T19:37:09.149179-06:00beckastarhttps://djangosnippets.org/snippets/10548/<p>I had a difficult time understanding how to delete an item from a table within a template, using a modelform. I couldn't find a good example, so I wanted to post the code that ultimately worked. </p>
Freely redistributableTemplate tag to render collections.Counter as an html table
2015-06-19T10:12:27.396198-05:00asfaltboyhttps://djangosnippets.org/snippets/10502/<p>Render a given instance of collections.Counter into a 2 column html table.</p>
<p>Optionally accepts <code>column_title</code> keyword argument which sets the table
key column header.</p>
<p>Usage:</p>
<pre><code>{% counter_table event_counter column_title='event type' %}
</code></pre>
<p>The above will render the a table from the <code>event_counter</code> variable with the first (key) column set to "event …</p>
Freely redistributableManage.py alterdb command
2012-07-18T10:14:20.603823-05:00certatorhttps://djangosnippets.org/snippets/2791/<p>added commands:</p>
<p>altersql - shows sql code with alter queries</p>
<p>alterdb - apply alter queries. parameters:</p>
<p>--showsql - show queries</p>
<p>--app=APPLICATION - alter only selected application</p>
<p><a href="https://bitbucket.org/certator/django_snippets">you need clone this repo</a></p>
Freely redistributableModelList class
2011-03-02T15:35:34.207725-06:00facundo_olanohttps://djangosnippets.org/snippets/2374/<p>This class makes easier the job of rendering lists of model instances in django templates. It's intended to mimic the behavior of the Model Forms in that it contains the code needed to render it as an HTML table and makes it easy to handle all the model lists from …</p>
Freely redistributableGroup sequence into rows and columns for a TABLE
2011-02-17T10:02:00.611304-06:00davidwtbuxtonhttps://djangosnippets.org/snippets/2361/<p>Two template tag filters that can be used to create a table from a sequence.
</p>
<pre><code><table>
{% for row in object_list|groupby_columns:3 %}
<tr>
{% for obj in row %}
<td>{{ obj }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</code></pre><p>The example above would create a table where items read …</p>
Freely redistributableDjango Row Level Locking (Prevents race conditions if used correctly)
2010-05-26T15:58:40.424111-05:00sleepycalhttps://djangosnippets.org/snippets/2039/<p><em>WARNING</em> This is <em>extremely</em> slow.
</p>
<p>This snippet allows you to easily prevent <em>most</em> race conditions (if used properly).
</p>
<p>Feel free to extend on top of this as you like, I'd appreciate any comments to cal@simplicitymedialtd.co.uk
</p>
Freely redistributableformat output as table
2009-07-14T14:51:53.015570-05:00bendavis78https://djangosnippets.org/snippets/1631/<p>Ever wished you could have pretty SQL-like output for a python object (e.g., a list of dicts) while you're debugging your code? This function will do just that. Simply pass it an object that is an iterable of dictionaries and it returns it in an easy-to-read table, similar to the …</p>
Freely redistributableUpdated table tag
2009-06-01T18:06:46.602741-05:00bl4th3rsk1t3https://djangosnippets.org/snippets/1542/<p>This table tag helps with render tables, which can be fairly complex.</p>
<p>I updated the previous table tag (296).</p>
<p>I added support for oddrow,evenrow,lastcellinrow,oddcol,evencol. And made a few minor adjustments to syntax formatting, and some non needed if conditionals</p>
<p>These are all of the supported variables available in the context …</p>
Freely redistributabledjango-plus cross table usage example
2009-04-24T05:48:48.886909-05:00marinhohttps://djangosnippets.org/snippets/1463/<p>Look more on:</p>
<p>http://code.google.com/p/django-plus</p>
Freely redistributableLocking tables
2008-06-30T03:49:32.722453-05:00miohtamahttps://djangosnippets.org/snippets/833/<p>Sometimes you need to prevent concurrent access to update/calculate some properties right. Here is (MySQL) specific example to lock one table with new object manager functions.</p>
Freely redistributableCalendar table
2008-04-24T20:37:37.053877-05:00fauxparsehttps://djangosnippets.org/snippets/722/<p>Creates a filter for displaying calendars.</p>
<p>Passed value is a dict of dicts of arrays: that is, indexed by year, then by month. The list of month days is used to generate links in the format specified by the argument. If a particular day is <em>not</em> in the list, then …</p>
Freely redistributableReshape list for table, flatten index in nested loops
2008-02-23T03:43:28.124494-06:00aquagnuhttps://djangosnippets.org/snippets/613/<p>Sometimes we want to render items as cells in table with fixed row-count and computable col-count shape and vice versa. It's not difficult to do it with compute odd and even row, col index, but more common way is to use some reshape function. Theare are simple TAG for it: …</p>
Freely redistributableTableSelectMultiple Widget
2007-12-19T09:49:50.732959-06:00insinhttps://djangosnippets.org/snippets/518/<p>A widget for selecting from a list of <code>Model</code> instances using <code>MultipleChoiceField</code> which renders a table row for each choice, consisting of a column for a checkbox followed by a column for each item specified in <code>item_attrs</code>, which must specify attributes of the objects passed as choices.</p>
Freely redistributableSort Table Headers
2007-07-11T16:25:41.589011-05:00insinhttps://djangosnippets.org/snippets/308/<p>Handles creation of <code>order_by</code> criteria based on GET parameters and provides context variables to be used when generating table header sort links which respect the current sort field and direction, reversing the direction when the same header is sorted by again.</p>
<p>Sample view:</p>
<pre><code>from somewhere import SortHeaders
from django.contrib.auth.models import …</code></pre>
Freely redistributableTable
2007-06-26T19:21:50.049185-05:00Samushttps://djangosnippets.org/snippets/296/<p>This is rough code that will allow you to create a table using a sequence. It is based on the for loop tag in django template. It works basically the same except that certain variables are set based on what cell is being rendered. The tag itself does not output …</p>
Freely redistributable