djangosnippets.org: Latest snippets posted by skamhttps://djangosnippets.org/users/skam/2015-02-09T09:18:23.499159-06:00skamget_querystring template tag
2015-02-09T09:18:23.499159-06:00skamhttps://djangosnippets.org/snippets/10463/<p>A Django Template tag used to construct urls with current querystring parameters. This is based on some code that I've written some years ago. Enjoy.</p>
Freely redistributabledjango-constance generic view
2015-02-09T09:13:23.204673-06:00skamhttps://djangosnippets.org/snippets/10462/<p>For several projects I am using generic views instead of django-admin, I needed a generic view for constance instead of using their django-admin based app.</p>
Freely redistributablerequire XMLHttpRequest view decorator
2008-01-29T05:42:15.880039-06:00skamhttps://djangosnippets.org/snippets/567/<p>Decorator to make a view only accept requests from AJAX calls. Usage::</p>
<pre><code>@require_xhr()
def my_view(request):
# Returns data
# ...
</code></pre>
<p>by <a href="http://skam.webfactional.com/">skam</a></p>
Freely redistributableBabelMiddleware
2007-07-16T09:32:54.467207-05:00skamhttps://djangosnippets.org/snippets/320/<p>Originally posted on <a href="http://skam.webfactional.com/blog/2007/07/16/babel-integration-django/">skam.webfactional.com</a></p>
<p>This is a very simple middleware that uses babel (http://babel.edgewall.org) for accessing locale data in request objects through request.LOCALE attribute.</p>
<p>It also provides a function to get locale data outside views.</p>
<p>settings.py:</p>
<pre><code>MIDDLEWARE_CLASSES = (
... cut ...
'django.middleware.locale.LocaleMiddleware',
'middleware.locale.BabelMiddleware',
... cut ...
)
</code></pre>
Freely redistributablejquery autocomplete widget
2007-05-13T15:54:42.448088-05:00skamhttps://djangosnippets.org/snippets/233/<p>newforms widget for autocompleting text fields using jquery autocomplete plugin: http://jquery.bassistance.de/autocomplete/</p>
<p>to be implemented:
- store the pk value into an hidden field
- handling ChoiceFields and many others</p>
<p>massimo dot scamarcia at gmail.com</p>
Freely redistributablejsonify template filter
2007-04-25T11:07:15.529389-05:00skamhttps://djangosnippets.org/snippets/201/<p>Simple template filter to encode a variable to JSON format</p>
<p>Usage:</p>
<p>{% load json_filters %}</p>
<p>{% block content %}
&lt;script type="text/javascript"&gt;<![CDATA[
var items = {{ items|jsonify }};
]]>&lt;/script&gt;
{% endblock %}</p>
<p>I'm using JsonResponse for the views but I also want to have preloaded JSON data into the page output</p>
Freely redistributableroman numbers template filter
2007-04-14T08:50:10.581744-05:00skamhttps://djangosnippets.org/snippets/178/<p>dirt and simple template filter to convert a number to its roman value. taken from dive into python http://www.diveintopython.org/unit_testing/stage_5.html</p>
Freely redistributabledjango-tagging clouds template tag
2007-03-28T16:39:43.157047-05:00skamhttps://djangosnippets.org/snippets/140/<p>template tag for producing tag clouds for a given model, using django-tagging application:</p>
<p>http://code.google.com/p/django-tagging/</p>
<p>Sample: http://skam.webfactional.com/tags/</p>
<p>Usage:</p>
<p>{% tags_cloud_for_model articles.Article as object_list %}
{% tags_cloud_for_model articles.Article as object_list step 6 %}</p>
Freely redistributable