Login

Snippets by mjt

Snippet List

PostgreSQL ON DELETE CASCADE

Have you always been annoyed by how you set up this elaborate big database schema and weren't able to have **ON DELETE CASCADE ON UPDATE CASCADE** in dbshell? This solves the problem; create the two files and and empty *__init__.py* and put them somewhere in your path. Then say DATABASE_ENGINE='postgresql_psycopg2_cascade' in settings. Really I'd like this to be in the ForeignKey object, were it upstream Django or an own version of it, but it doesn't seem possible. Ideas on how to make this configurable are more than welcome! Props go out to Ari Flinkman for the inspiration to do this!

  • database
  • postgres
  • foreign-key
  • postgresql
  • databases
Read More
Author: mjt
  • 1
  • 1

django-noserun for testing

I wanted to use Nose with Django so I came up with this. `TEST_RUNNER = 'noserun.run_tests'` in settings.py It does not do setup/teardown implicitly between test methods, you need to call *nosetest.test.flush()* and *nosetest.test.loaddata()* manually if you want that. Enables the method names *setup* and *teardown* The environment variable *NOSE_COVER* runs coverage tests and *NO_DROPDB* preserves the test db.

  • testing
  • test
  • nose
Read More
Author: mjt
  • 1
  • 2

mjt has posted 2 snippets.