update primary key (and cascade to child tables)
Management command to update a primary key and update all child-tables with a foreign key to this table.
- primary-key
- cascade
Management command to update a primary key and update all child-tables with a foreign key to this table.
If you use this pattern to track changes in the auth user table: from django.contrib.auth.models import User from reversion.helpers import patch_admin patch_admin(User) you can't see important changes, since a version is created for every login if a user. If you want to get rid of changes which only change unimportant stuff you can use this middleware. This middleware can be used for every model. Just use this pattern in your settings: REVERSION_CLEAN={ 'django.contrib.auth': {'User': ['last_login']}, }
See docstring
See docstring
This django.db.models.Field stores a list of python strings in one database column.
DEPRECATED: Django has cookie based messages since version 1.2 This messages stores messages for the user in a cookie. I prefer this to session based messages, because the session column is a hot spot in the database if one user works with several browser tabs/windows.
If you app defines some URLs with a name, and you want to overwrite this at project level with a different view you can use this snippet. You only need to change on line in the application code (the import statement).
has_perm.py: Check if a user can access a view without calling it One of the goals: You can disable or hide a link if the user must not call it.
Deprecated! I use south in all applications with database backend now.
I think this method is handy, since you don't need to remember if you need urlquote or urlencode. It does both and adds a question mark between the path and the get parameters, if later are present. And it works around a bug in Django: MultiValueDicts (request.GET, request.POST) are handled correctly. Related: [http://code.djangoproject.com/ticket/9089](http://code.djangoproject.com/ticket/9089)
If you need two values for validation, you can't use clean_value_a() since it is undefined if value_a or value_b gets cleaned first. This little helper lets you add ValidationErrors to fields instead of \__all\__. Related [Ticket 5335](http://code.djangoproject.com/ticket/5335).
This subclass of django.models.Field stores a python datetime.timedelta object as an integer column in the database. It includes a TimedeltaFormField for editing it through djangos admin interface. Feedback welcome. 2011-04-20: TimedeltaField can now be (de)serialized. Tested with JSON. 2009-11-23: `_has_changed()` added. Before form.changed_data contained timedelta FormFields, even if nothing changed.
With this script you can create a simple breadcrumbs line for navigation: Home >> Page >> Subpage ...
Changing the size of max_length in the model is fast. But sometimes you forget to update all running systems which use this model. This unittest helps you to find the difference between Model and DB before the users get uncaught exceptions.
Maybe there is a better solution, feedback welcome!
guettli has posted 22 snippets.