Login

Tag "runtime"

Snippet List

Unit Test Profiling for Django 1.3/1.4

The snippet is a modification of [snippet 1315](http://djangosnippets.org/snippets/1315/) to fit the needs for Django 1.3 and 1.4. You can follow the explanations and instructions there. To plot a nice and so useful call-graph with timings, call: $ gprof2dot -f pstats unittest.profile | dot -Tpng -o unittest.profile.graph.png where 'unittest.profile' is the test runners profile output defined in your settings.

  • profile
  • unittest
  • runtime
  • cprofile
Read More

Dynamic Django form

This is a little snippet that you can use to make your Django newforms dynamic at runtime. You can define an arbitrary number of fields of the form without loosing newforms capibilites. You can render the form dynamically be "misusing" the "help_text" attribute of the form fields (Every form field allows the definition of this attribute). This way you can search for changes in the help_text of every field and render the form accordingly. The form itself is dynamically defined in the view. The form state can be saved in a Django Session Variable (specifically for Linux users with a process-based Apache Server), so that you can rebuild and verify a submitted form.

  • newforms
  • dynamic-form
  • runtime
  • custom-forms
Read More

2 snippets posted so far.