This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
fhen (author)
Sat Aug 15 07:39:08 -0700 2009
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Fri Aug 14 13:38:03 -0700 2009 | |
| |
README.md | Sat Aug 15 05:34:37 -0700 2009 | |
| |
__init__.py | Fri Aug 14 13:38:03 -0700 2009 | |
| |
admin.py | Sat Aug 15 05:34:37 -0700 2009 | |
| |
fields.py | Sat Aug 15 07:39:08 -0700 2009 | |
| |
models.py | Sat Aug 15 07:39:08 -0700 2009 | |
| |
settings.py | Sat Aug 15 05:34:37 -0700 2009 | |
| |
templatetags/ | Sat Aug 15 07:39:08 -0700 2009 | |
| |
utils.py | Sat Aug 15 07:39:08 -0700 2009 | |
| |
views.py | Fri Aug 14 13:38:03 -0700 2009 |
README.md
DiffField
DiffField is django model field that stores self change history in database. DiffField is ancestor of models.TextField, stores data in Diff model. Stored data is link to the object, author of the change and change in own internal diff format (truncated Python's difflib.ndiff format).
Note! Changes doesn't take an effect when using update method to modify this field! It's not good idea! This problem should be fixed.
Usage
settings.py
MIDDLEWARE_CLASSES = (
... # Not required, see below
'django_utils.middleware.threadlocals.ThreadLocals',
)
INSTALLED_APPS = (
.....
'diffield',
.....
)
# Save full text in history, not diffs (in every diff)
DIFF_SAVE_FULL_TEXT = False
# Enable periodic text caching in database (every N revisions)
DIFF_CACHE_TEXT = True
# Save full text every SAVE_TEXT_CACHE_PERIOD times (the period of caching)
DIFF_SAVE_TEXT_CACHE_PERIOD = 50
# Track users' contribution (save diffs' authors)
DIFF_TRACK_USERS = True
# Some function returning auth.models.User object
# Must be set if ThreadLocals is not used and DIFF_TRACK_USERS is True
DIFF_CURRENT_USER_FUNCTION = some_function
appname.models.py file
Field contributes to a class as TextField. Usage with null=True is not tested yet.
class MyModel(models.Model):
title = DiffField(u'title')
getting text of some revision
from diffield.models import Diff
Diff.objects.get(**kwargs).text







