{ Snipperize } /django

Snippets about django

Here are the latest snippets talking about django. Please choose your favorite one or add a new one.

Django JSON Form Field

This is a python form field that allows you to post JSON data to a form. The form field will validate it is JSON data and return the parsed dictionary object in cleaned_data.

Python / json, forms, django, field / by ThePeppersStudio (241 days, 14.03 hours ago)

SlugProperty for App Engine based on Django's SlugField

App Engine lacks an equivalent to Django's SlugField property. This code is a (very rough) attempt at creating such a property for App Engine. Three important points should be kept in mind when using this. One is that this is not heavily tested. It has worked for me so far, but only in minor testing situations. Two, realize that the slug is automatically calculated every time, so do not count on the slug to be stable if the property you attach it to changes. And three, do not try to access the slug field until you have put the model instance into the datastore! Because of the information given by App Engine to the default_value method it prevents the calculation of the slug from the property being relied upon.

Python / appengine, django, SlugProperty / by ThePeppersStudio (241 days, 14.13 hours ago)

Django code highlight template filter

A django template filter that highlights code with pygments.

Python / template, pygments, highlight, code, filter, django / by ThePeppersStudio (241 days, 14.16 hours ago)

Sometimes Tag

Adds a templatetag that works like an if block, but . The one and only argument is a float that reflects the percentage chance. It defaults to .2, %20. {% sometimes %} {% else %} {% endsometimes %} -- or -- {% sometimes .001 %} You win! {% else %} Sorry, not a winner. Play again! {% endsometimes %} -- or -- {% sometimes .5 %} This shows up half the time. {% endsometimes %}

Python / templatetag, django / by prof.syd.xu (261 days, 21.07 hours ago)

Generic AJAX app

This is based on the Admin app functionality for dispatching calls. Once you put these two files in place then add the following to urls.py: from django.contrib import ajax urlpatterns = patterns('', ... # Add this to the urlpatterns list (r'^ajax/(.*)', ajax.dispatcher.urls), ...) you register a function or method with a name like so: from django.contrib import ajax def myAutoCompleteCall(request): ... ajax.dispatcher.register('myAutoComplete', myAutoCompleteCall) Then you can use the url: http://www.mysite.com/ajax/myAutoComplete You could place this app in the django\contrib directory if you wanted to use it in an Admin app mod

Python / django, ajax, dispatcher / by prof.syd.xu (261 days, 21.24 hours ago)

  • 1