In vanilla django, if you wanted to `{% load foo_tags %}, what you did wsa to create a importable templatetags namespace with a foo_tags.py
like this:
/
|- settings.py
|- manage.py
|- ...
|- templatetags/
|- __init__.py
|- foo_tags.py
But with Google App Engine's django (0.96), it's not so easy. The tag ...
Recently, I found myself trying to create a model form with fields spanning multiple models. I knew I could just re-define the fields manually, but that makes for poor maintainability (read: too lazy to type).
After some digging in ModelFormMetaclass
and modelform_factory()
, here's what I came up with:
from ...
This monkey-patches django.tests.testcases.TestCase
so that all tests in a TestCase
take place in a BEGIN
transaction, while test methods take place in a nested transaction, with a savepoint being recorded after fixtures are loaded before a test, and rolling back to it after ...
Afaik, only the Oracle and Postgres backends has this; sqlite already has it for almost a year now, but there still isn't support for it in django.
I've posted a patch for inclusion; it'll be interesting to see how it goes.
For TestCases that use yaml fixtures, and/or if your app contains initial data fixtures, they'll get loaded and parsed for every test method - yep, you read that right.
You can get a nice performance boost by caching parsed yaml fixtures/memoization.
Edit: Note that this won't kick ...
Here's a quick script to append {% csrf_token %}
at the end of the opening <form>
tag across your html files:
$ grep -REli --include="*.html" "<form.+method[[:space:]]?=[[:space:]]?['\"]?post['\"]?" . \
| xargs sed -i -re "s|(<form.+method[^=]*=\W?post[^>]+>)|\1{% csrf_token %}|i"
For git users, you can use git-grep
instead of ...