Login

Snippets by crucialfelix

Snippet List

unique_slugify

sorry, this is a duplicate post, original is here: http://www.djangosnippets.org/snippets/690/ no way to delete snippets

  • slug
  • slugify
Read More

UnitTesting without create/destroy database

This test runner is invoked with its own command: ./manage.py quicktest {usual test args follow} this creates a test database if it needs to and then DOES NOT delete it. subsequent uses of it start with the same database. this is for rapid test/development cycles usually running a single test. a single test can run in less than a second. when you need to alter the schema simply use the normal ./manage.py test which will delete the old test database and create a fresh one. it does not replace your normal test runner. it could probably be altered to even use your custom test runner. there are improvements to be done, and it will be included with a small testy app soon.

  • unittest
Read More

DebugFooter middleware with textmate links

a minor remix of simon's debug footer: <http://www.djangosnippets.org/snippets/766/> > Adds a hidden footer to the bottom of every text/html page containing a list of SQL queries executed and templates that were loaded (including their full filesystem path to help debug complex template loading scenarios). This version adds TextMate links : if you are working on your local machine and using TextMate you can click on the template paths and they will be opened in TextMate. This speeds up development time considerably ! also, this works with django 1.0 (simon's version got broke by the 'connect' refactor) update: the view function is now linked > To use, drop in to a file called 'debug_middleware.py' on your Python path and add 'debug_middleware.DebugFooter' to your MIDDLEWARE_CLASSES setting.

  • middleware
  • debug
  • textmate
Read More

Model inheritance with content type

Contact is a parent class. Subclasses might be Company, Person, Artist, Label etc. Basic address, email etc. fields can be added to the parent class and all subclasses will have those. Having searched your database for contacts (undifferentiated by class) you then want to reload the chosen object as the subclass that it really is : ``thing.as_leaf_class``

  • inheritance
Read More

crucialfelix has posted 4 snippets.