Snippet List
Tag to inspect template context, filter to inspect variable.
Originally by denis, [http://www.djangosnippets.org/snippets/1550/](http://www.djangosnippets.org/snippets/1550/).
This just extracts variables from the context to locals for quicker access and autocompletion (When using ipdb).
Additionally, 'vars' holds context keys for quick reference to whats available in the template.
- template
- debug
- context
- pdb
- ipdb
Save to autotranslate.py, run using python autotranslate.py pofile inputlang outputlang, eg. python autotranslate.py path_to_blank_fr_lang.po en fr, to translate to french.
Some known bugs:
* Doesn't handle some line returns properly
* Block translations aren't formated correctly in the translation.
If anyone has any issues or fixes please post to the comments.
Of course the output shouldn't be used as substitute to a proper translation.
Best practice based on [YSlow recommendations](http://developer.yahoo.com/yslow/), add the following to your Apache config for your media directory.
<Directory /home/.../site_media/>
...
FileETag None
ExpiresActive on
ExpiresDefault "access plus 10 years"
AddOutputFilterByType DEFLATE text/css application/x-javascript
</Directory`
Make sure to enable mod_deflate and mod_expires.
- templatetag
- css
- media
- js
- versioned_media
! Note - no longer needed
Save this script in the same directory as manage.py and run it through the command line.
It picks up project Command class instances. Something that will hopefully be fixed in the Django SVN version soon.
Heres an example of a command:
#utils/management/commands/sqlallall.py
from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.db import models
class Command(BaseCommand):
help = "Returns sqlall for all installed apps."
def handle(self, *args, **options):
"""
Returns sqlall for all installed apps.
"""
for app in models.get_apps():
call_command("sqlall", app.__name__.split(".")[-2])
Allows for a quick startup loading commonly used classes, installed apps, and console utils.
To use: After manage.py shell, enter from somepath.startup import *.
dnordberg has posted 7 snippets.