This view assumes you have downloaded [modelviz.py](http://django-command-extensions.googlecode.com/svn/trunk/extensions/management/modelviz.py) and placed it in a python module called utils within my_project. You also must have graphviz installed and a subprocess-capable python. From there you can feed it a URL query list of the options you want to pass to generate_dot, and it will dynamically draw png or svg images of your model relationships right in the browser. All it wants is a nice form template for graphically selecting models. Most of this code and the main idea thereof was shamelessly plagiarized from [someone else](http://gundy.org/).
Examples:
`http://localhost:8000/model_graph/?image_type=svg&app_labels=my_app&include_models=Polls&include_models=Choices`
`http://localhost:8000/model_graph/?image_type=png&all_applications&disable_fields&group_models`
The nested set abstraction is a very nice way to store hierarchical data, for example places, in a database. It provides an easy way to say that Melbourne is within Victoria, which is within Australia, etc.</p>
The calls to addChild() are expensive, so this model is slow to build, and bad if you do frequent updates. If you're building a read-only model though, it's much faster than ForeignKey('self') for determining ancestor/descendent relationships.
put this code into a file in a folder "templatetags" inside some application and use it like this:
{% load your_file_name %}
{% for item in your_list|order_by:"field1,-field2,other_class__field_name"
I'm developing a regionalization extension based on PostGIS and GeoDjango for a web-based LCA software. Because PostGIS (or PostgreSQL) is not available everywhere, we needed a way to fully disable the geographic extensions.
Because of that, I set out to create a template block tag which only gets evaluated when GIS support is active and totally ignored (treated as a comment) otherwise.
I had some problems getting my BoringNode to work (which should just pass the content through), so I've just used the AutoEscapeControlNode (why? Because it was the first usable class that jumped into my eye.) for this purpose.
Displays an input with an add button. Clicking the add button creates a simple form - input with a submit button. Clicking the submit button will send the output to the server and return a value which is displayed.
This filter converts a XHTML-compatible shorttag `<input ... />` to a HTML4-compatible tag `<input ...>`.
Example:
`{% for field in form %}
<dt>{{ field.label_tag }}</dt>
<dd>
{{ field.errors }}
{{ field|remove_shorttag }}
</dd>
{% endfor %}`
This will produce html4-compatible output, opposed to newform's normal XHTML output.
We had some fun today on the #django IRC channel searching and counting through past logs for people saying "thanks" to [a known very helpful person](http://djangopeople.net/magus/).
Here's a unix shell script for checking your own score if you're using Pidgin and have logging turned on.
Replace ".purple" with ".gaim" in the script if you're using Gaim (an older version of Pidgin).
"Sharedance is a high-performance server that centralize ephemeral key/data pairs on remote hosts, without the overhead and the complexity of an SQL database." [Frank DENIS](http://sharedance.pureftpd.org/project/sharedance)
django.contrib.formtools in preview displaying only field.data by default. Its not convenient to see integer value for fields with radio buttons or select choices.
This custom tag trying to show string value from choices if available.
This template tag and suggested template allow greater control over rendering `<label>` tags for your newforms fields than using `field.label_tag`. I save the provided Python code in my app as `templatetags/forms.py` (although this name may conflict in the future).
The simplest usage:
{% label field %}
One use case is adding `class="required"` to the label tag for required fields instead of inserting markup elsewhere--this is done in the given example template.
Alternate label text and tag attributes can be passed to the inclusion tag:
{% label field "Alt. label" 'class=one,id=mylabel' %}
This is an extension to ubernostrum's [comment-utils](http://code.google.com/p/django-comment-utils/) that performs comment moderation based on LinkSleeve check result. It requires original comment-utils package.
You're looking at the top-rated snippets currently on the site; if you'd like to contribute, sign up for an account and you'll be able to rate any snippet you see.