Skip to main content

miscellaneous tools for django

Project description

Miscellaneous tools for django.

existing stuff

local sync cache

Keep a local dict in a multi-threaded environment up-to-date. Usefull for cache dicts. More info, read DocString in ./local_sync_cache/

limit to usergroups

Limit something with only one field, by selecting:

  • anonymous users
  • staff users
  • superusers
  • ..all existing user groups..

More info, read DocString in ./

DOM compare in unittests

The Problem: You can’t easy check if e.g. some form input fields are in the reponse, because the form rendering use a dict for storing all html attributes. So, the ordering of form field attributes are not sorted and varied.

The Solution: You need to parse the response content into a DOM tree and compare nodes.

We add the gread work of Gregor Müllegger at his GSoC 2011 form-rendering branch. You will have the following assert methods inherit from: django_tools.unittest_utils.unittest_base.BaseTestCase

  • self.assertHTMLEqual() – for compare two HTML DOM trees
  • self.assertDOM() – for check if nodes in response or not.
  • self.assertContains() – Check if ond node occurs ‘count’ times in response

More info and examples in ./tests/

upgrade virtualenv

A simple commandline script that calls pip install —-upgrade XY for every package thats installed in a virtualenv. Simply copy/symlink it into the root directory of your virtualenv and start it.

Note: Seems that this solution can’t observe editables right.

To use it, without installing django-tools:

~/$ cd goto/your_env
.../your_env/$ wget
.../your_env/$ chmod +x
.../your_env/$ ./

This script will be obsolete, if pip has a own upgrade command.

..all others…

There exist many miscellaneous stuff. Look in the source, luke!

Backwards-incompatible changes


Language code field and SelectMediaPath are renamed.

change: from django_tools.fields import LanguageCodeFormField to: from django_tools.fields.language_code import LanguageCodeFormField

change and rename: from django_tools.fields import LanguageCodeField to: from django_tools.fields.language_code import LanguageCodeModelField

change and rename: from django_tools.widgets import SelectMediaPath to: from django_tools.fields.media_path import MediaPathWidget


  • v0.19.4

    • Bugfix for PyPy in local_sync_cache get_cache_information(): sys.getsizeof() not implemented on PyPy
    • Bugfix in template.filters.chmod_symbol()
    • Nicer solution for template.filters.human_duration()
  • v0.19.3

    • Add support for https in utils/
  • v0.19.2

    • Bugfix in utils/ timeout work-a-round
  • v0.19.1

    • utils/ changes:

      • Use a better solution, see:
      • Add timeout and add a work-a-round for Python < 2.6
  • v0.19.0

    • NEW: Add utils/ with helpers to get a webpage via http GET in unicode
    • Change README from textile to creole ;)
  • v0.18.2

    • Bugfix: Add missing template in pypi package
  • v0.18.0

    • NEW: Add DOM compare from Gregor Müllegger GSoC work into unittest utils.
  • v0.17.1

    • Bugfix in “limit_to_usergroups”: Make choices “lazy”: Don’t access the database in init
  • v0.17

    • Add the script “”
    • Add “limit_to_usergroups”
    • Add “local sync cache”
    • Add models.UpdateInfoBaseModel
    • Update decorators.render_to
    • render_to pass keyword arguments to render_to_response() (e.g.: mimetype=“text/plain”)
    • new argument “skip_fail” in get_filtered_apps(): If True: raise excaption if app is not importable
  • v0.16.4

    • Bugfix: get_db_prep_save() got an unexpected keyword argument 'connection’ when save a SignSeparatedModelField()
  • v0.16.3

    • Update BrowserDebug: Use response.templates instead of response.template and make output nicer
  • v0.16.2

    • Merge stack info code and display better stack info on browser debug page
  • v0.16.1

    • Update django_tools.utils.messages.StackInfoStorage for django code changes.
  • v0.16.0

    • NEW: path model field (check if direcotry exist)
  • v0.15.0

    • NEW: Add a flexible URL field (own validator, model- and form-field)
  • v0.14.1

    • Bugfix: make path in MediaPathModelField relativ (remove slashes)
  • v0.14

    • NEW: django-tagging addon: Display existing tags under a tag field
  • v0.13

    • Bugfix UnicodeEncodeError in Browser debug
  • v0.12

    • NEW: django_tools.utils.messages.failsafe_message
  • v0.11

    • NEW: Store data in a secure cookie, see: utils/
  • v0.10.1

    • New: Display used templates in unittest BrowserDebug
    • Bugfix: catch if last usermessages exist
  • v0.10.0

    • NEW: utils around django messages, see: /django_tools/utils/
  • v0.9.1

    • Bugfix: database column was not created: don’t overwrite get_internal_type()
  • v0.9

    • New: stuff in /django_tools/fields/
    • see also backwards-incompatible changes, above!
  • v0.8.2

    • New: widgets.SelectMediaPath(): Select a sub directory in settings.MEDIA_ROOT
    • New: fields.SignSeparatedField()
  • v0.8.1

    • Add “no_args” keyword argument to installed_apps_utils.get_filtered_apps()
  • v0.8.0

    • Add model LanguageCode field and form LanguageCode field in Accept-Language header format (RFC 2616)
  • v0.7.0

    • Add
  • v0.6.0

  • v0.5.0

    • Add template/ from PyLucid v0.8.x
  • v0.4.0

    • Add experimental “warn_invalid_template_vars”
  • v0.3.1

    • Bugfix: Exclude the instance if it was saved in the past.
  • v0.3.0

    • Add utils.installed_apps_utils
  • v0.2.0

  • v0.1.0

pip upgrade

To do a pip upgrade in a virtual environment, run this:

~$ cd /YourVirtualEnv/bin
~/YourVirtualEnv/bin$ source activate
(YourVirtualEnv)~/YourVirtualEnv/bin$ pip install --upgrade --verbose --editable=git+git://

The example used git readonly clone url. If you use subversion do this:

(YourVirtualEnv)~/YourVirtualEnv/bin$ pip install --upgrade --verbose --editable=

If you have git write access, use this:

(YourVirtualEnv)~/YourVirtualEnv/bin$ pip install --upgrade --verbose

…or just use our script (see above)

fast repo update

To made a fast repository update, you can run this simple shell script:

~$ cd /path/to/django-tools
/path/to/django-tools$ ./

the update script runs “git pull origin master” or “svn update”.

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-tools- (40.1 kB) Copy SHA256 hash SHA256 Source None Sep 6, 2011

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page