Python Google Translate AJAX module
Based on http://code.google.com/p/py-gtranslate/ Removed YAML dependency and list of languages. Instead it use 2-symbol codes for languages.
- ajax
- translate
Based on http://code.google.com/p/py-gtranslate/ Removed YAML dependency and list of languages. Instead it use 2-symbol codes for languages.
Suitable for use with DecimalField. Handy for accurate timing input (think sports, racing etc.).
in this case the 'render_template' decorator assumes there is a myview.html template. this keeps things simple and you DRY. Hope it helps. Regards, Paul
This field is similar to the standard URLField, except it checks the given URL for a HTTP 301 response (permanent redirect) and updates its value accordingly. For example: >>> url = RedirectedURLField() >>> url.clean('http://www.twitter.com/') >>> 'http://twitter.com/' In models: class TestModel(models.Model): url1 = RedirectedURLField('Redirected URL') url2 = models.URLField('Standard URL')
Accepts the same arguments as the 'range' builtin and creates a list containing the result of 'range'. Syntax: {% mkrange [start,] stop[, step] as context_name %} For example: {% mkrange 5 10 2 as some_range %} {% for i in some_range %} {{ i }}: Something I want to repeat\n {% endfor %} Produces: 5: Something I want to repeat 7: Something I want to repeat 9: Something I want to repeat
Here my piece of code for managing users with WSGIAuthUserScript.
a simple bad word filter. usage: {{ post.content|audit }}
Modifies the as_sql methods to print the queries.
Extend this ModelAdmin to get dynamic inline previews in the list admin also lives here: [http://github.com/broderboy/django-admin-preview](http://github.com/broderboy/django-admin-preview)
This template tag finds FlatPages with urls 'similar' to the given request_path. It takes the request_path from the page_not_found view (django.views.defaults), picks it apart, and attempts to match existing FlatPages that have a 'similar' URL. For example, if the URL that resulted in a 404 was: /foo/bar/baz/whatever/ This tag would look for FlatPages whose URL starts with the following: /foo/bar/baz/whatever/ /foo/bar/baz/ /foo/bar/ /foo/
When you have a model containing a field that is a foreign key back to the same model, you could find yourself with a hierarchy with an infinite loop: #Data modelling Back to the Future > grandfather > father > son > father > ... Using this field instead of the standard ForeignKey will ensure that no model instance is saved that has itself as an ancestor, breaking the relationship if it does. (Enhancements: I am sure one would want to better enhance this with appropriate error handling instead of silently disconnecting the relationship. And the relevant forms ought not show ancestors in the field's widget to reduce the chances of this happening in the first place.)
Useful in sumbiting data . Remember to use form.save_m2m() :)
I miss the ability to use testmodels in app-tests. Using this testrunner you can include a test "app" in the app's tests module. Say if you have a module test_app.models within the tests module you could use it in the test like this: from django.test import TestCase from some_django_app.tests.test_app import models as testingmodels TEST_APPS = 'test_app' class ATestCase(TestCase): def test_no_url_model_signals(self): thing = testingmodels.ThingModel(name=u'a small thing') `TEST_APPS` can either be a string, a list or a tuple. This testrunner works with Django 1.1. It is based on the simple testrunner included with Django.
Generates admin.py file for a models.py file with the basic structure that could be edited. Usage: python gen_admin_py.py path/to/models.py creates a file admin.py in the same directory as models.py. import your models as you edit the admin.py
This tag is meant to mimic the python use of range in a for-loop: 'for i in range(start, end, step)'. It is implemented like a loop and it takes both variable names from the context and constant integers as arguments. Syntax: {% range end as i %} {{ i }} {% endrange %} {% range start:end as i %} {{ i }} {% endrange %} {% range start:step:end as i %} {{ i }} {% endrange %}
3110 snippets posted so far.