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 ...
And therein lies the best career advice I could possibly dispense: just DO things. Chase after the things that interest you and make you happy. Stop acting like you have a set path, because you don’t. No one does. You shouldn’t be trying to check off the boxes ...
If you've been following my gists and my bloggart fork, then you're probably aware that some time back, I added a simple memcache-based memoizer. I applied to BlogPost
operations that I thought were computationally expensive - hashing and markup rendering.
Of course, you can't call something an optimization ...
You're probably doing this:
$ git branch | grep \*
* master
Try this:
$ git rev-parse --symbolic-full-name HEAD
refs/heads/master
Substantial typing required, though.
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.
Perusing the builtin-sqlite3 docs, as well as those of pysqlite, doesn't seem to offer much clue to using these.
After lots of hair-tearing, I think I've got it figured out.
Here's what most people usually do on their first try:
cur1.execute("create table test(i)")
cur1 ...
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 ...
You'll notice that requests to this blog's feed no longer redirects to Feedburner, as I've decided to do away with it.
Right now, FB doesn't offer meaningful statistics, since readership is negligible. Also, doing 301 redirects outside of the site, as my implementation does, is suboptimal ...
In case you're wondering, the syntax/format is similar to what you would use for specifying dependencies in a setup.py
.
Here's a fairly complex example of loading a recent django 1.1, but not 1.2:
>>> from pkg_resources import require
>>> require("django >=1.1, <1.2")
[django ...