Kitdjango
lck.django: a reusable library of typical Django routines, apps, filters, template tags and configuration techniques.
Install / Use
/learn @ambv/KitdjangoREADME
========== lck.django
This library consists of various Django-related routines that extend or modify the behaviour of the framework:
-
lots of composable abstract models to use
-
a user activity log app storing users' IP addresses and user agents (useful for hunting down multi-accounts)
-
a
scoreapp enabling users on websites to vote on objects -
a
tagsapp which supports tagging by users and localized tags -
a
badgesapp which enables users to receive badges for actions on the website -
extensions for
settings.py(current directory resolution, namespace package support, settings profile support) -
typical filters, template tags, form fields, etc.
Complete documentation for the package can be found here:
http://packages.python.org/lck.django/
The latest version can be installed via PyPI <http://pypi.python.org/pypi/lck.django/>_::
$ pip install lck.django
or::
$ easy_install lck.django
The source code repository <http://github.com/ambv/kitdjango>_ and issue tracker <http://github.com/ambv/kitdjango/issues>_ are maintained on
GitHub <http://github.com/ambv/kitdjango>_.
This package bundles some royalty free static images that are useful in almost every Django project:
-
Silk icons 1.3 by FamFamFam <http://www.famfamfam.com/lab/icons/silk/>_- requires attributing the author
-
Silk Companion 1 by Damien Guard <http://damieng.com/creative/icons/silk-companion-1-icons>_ - requires attributing the author -
Country Flags by SenojFlags.com <http://www.senojflags.com>_ - requires using the following HTML::<a href="http://www.senojflags.com">Country flag</a> image from <a href="http://www.senojflags.com">Flags of all Countries</a>
For the curious, lck stands for LangaCore Kit. LangaCore is a one man
software development shop of mine.
Note: lck.common requires Python 2.7 because all of its code is using
the so-called four futures (absolute_imports, division, print_function
and unicode_literals). One of the virtues in the creation of this library
is to make the code beautiful. These switches give a useful transitional
state between the old Python 2.x and the new Python 3.x. You should use them as
well.
Note: Since 0.5.0 lck.django requires Django 1.3 because
it makes my monkey-patching efforts much easier. Moreover, 1.3 nicely deprecates
behaviour which I consider ugly.
How to run the tests
The easiest way would be to run::
$ DJANGO_SETTINGS_MODULE="lck.dummy.settings" DJANGO_SETTINGS_PROFILE="test" django-admin.py test
This command runs the internal Django tests as well and that's fine because there are monkey patches and other subtleties that should better be tested for potential breakage.
The dummy project is also used as an example of setting up a Django project.
However, it seems Django tests are not happy with some changes to the settings
so we're using the test profile (which loads overrides from
settings-test.py) to avoid that.
Change Log
0.8.10
* ``profile`` now properly rolls back a failed transaction in
``create_a_user_profile_ignoring_dberrors()`` (fixes initial syncdb's
superuser creation on PostgreSQL)
* introduced automatic resolution of dependencies for initial migration. If
you use ``activitylog``, ``badges``, ``score`` or ``tags``, unless you're
using the plain ``auth.User``, their initial migrations depend on your
profile module being ready. Migrations currently depend on the initial
migration of your respective ``ACTIVITYLOG_PROFILE_MODEL``,
``EDITOR_TRACKABLE_MODEL``, ``SCORE_VOTER_MODEL`` or ``TAG_AUTHOR_MODEL``. If
those migrations should depend on a different migration or none, new settings
have been added.
0.8.9
~~~~~
* fixed a regression from 0.8.8 in synchronous ``activitylog`` models
* ``dj.choices`` requirement bumped to 0.9.2 (support for Python 2.6 - 3.3)
* ``dj.chain`` requirement bumped to 0.9.2 (support for Python 2.7 - 3.3)
0.8.8
~~~~~
* ``activitylog`` now properly encloses database updates in transactions
* ``activitylog`` on RQ and Celery now properly handles non-null constraints on
models
* ``SessionAwareLanguageMiddleware`` simplified, now simply sets the language
argument in the session. This requires changing middleware order: this
middleware should come after ``SessionMiddleware`` and before
``LocaleMiddleware``.
* The default ``INSTRUMENTATION_RULE`` is now simply ``lambda request: False``
which makes ``TimingMiddleware`` behave better with front-end caches (if
session is not accessed, ``Vary: Cookie`` is not set).
0.8.7
~~~~~
* ``activitylog`` now sports new async modes with built-in support for RQ or
Celery workers
* minor performance updates in ``tags`` models
0.8.6
~~~~~
* minor performance updates in ``activitylog`` middleware. Now behaves better
in low-memory + slow I/O environments.
0.8.5
~~~~~
* ``whois`` management command introduced to help find users by session ID
* using ``User`` attributes proxied from a ``Profile`` instance no longer
causes a query for each call
0.8.4
~~~~~
* ``TimeTrackable`` models can now force marking fields as dirty with
``mark_dirty()`` and ``mark_clean()`` methods
0.8.3
~~~~~
* ``concurrent_get_or_create`` will now raise AssertionErrors if given either
too many fields (e.g. not all of which are unique or compose
a unique-together constraint) or too few (e.g. fields do not form a whole
unique-together constraint). Non-unique fields should be passed in the
``defaults`` keyword argument if needed at object creation time.
* ``profile`` now implements automatic profile account synchronization by
registering a post-save signal on User and creating an ``AUTH_PROFILE_MODEL``
instance. A management command for existing applications called
``sync_profiles`` has been created.
* Unit tests converted to unittest2 format
0.8.2
~~~~~
* fixed regression from 0.8.1: removed savepoint support since the updated
``concurrent_get_or_create`` fails miserably on MySQL due to dogdy savepoint
support in `MySQL-python <http://pypi.python.org/pypi/MySQL-python>`_
0.8.1
~~~~~
* ``concurrent_get_or_create`` based on ``get_or_create`` from Django 1.4.2
* ``namespace_package_support`` extended to cover ``django.utils.translation``
as well (previously namespace-packaged projects only worked with I18N if
``setup.py develop`` or ``pip install -e .`` was used to install them)
* ``dj.chain`` requirement bumped to 0.9.1 (supports more collective methods)
0.8.0
~~~~~
* ``lazy_chain`` moved to a separate `dj.chain
<http://pypi.python.org/pypi/dj.chain/>`_ package. The old interface is thus
deprecated and will be removed in a future version.
* ``activitylog`` updates: removed redundant user fields so it works again with
``ACTIVITYLOG_PROFILE_MODEL`` set to ``auth.User``
* ``EditorTrackable`` doesn't require overriding ``get_editor_from_request``
anymore if ``EDITOR_TRACKABLE_MODEL`` is set to a profile model instead of
``auth.User``
* profile admin module includes a predefined ``ProfileInlineFormSet`` for
inclusion of profile-tied models to the ``UserAdmin`` as inlines
* the dummy application now passes all internal Django unit tests in versions
1.4.0 - 1.4.2
0.7.14
-
lazy_chain: the fix from 0.7.13 introduced a different kind of bug, reverted and fixed properly now. More tests included. -
flatpagesnow serve content in the default language if the language requested by the browser is unavailable. -
some internal cleanups
0.7.13
* ``lazy_chain``: when iterating over a slice, the iterator fetched one item too
many. It didn't yield it back so the result was correct but if using
``xfilter()`` that caused unnecessary iteration.
* ``dj.choices`` requirement bumped to 0.9.0 (choices are ``int`` subclasses,
``unicode(choice)`` is now equivalent to ``choice.desc``)
0.7.12
-
namespace package support now works with Unicode literals in settings.py
-
dummy app settings refinements: timing middleware moved down the stack because it uses the user session, WSGI app definition was wrong
0.7.11
* No code changes
* ``dj.choices`` requirement bumped to 0.8.6 (fully compatible with
0.8.5 and significantly improves ``ChoiceFields``)
0.7.10
-
BACKLINKS_LOCAL_SITESsetting to control if all configured sites should be considered local upon backlink discovery -
More backlink fixes data model fixes to make it more cross-compatible with different backends
0.7.9
* Fixed backlink hash generation in ``activitylog``
* ``activitylog`` accepts UTF-8 characters in ``User-Agent`` headers
* ``activitylog`` South migration #0002 now also works on backends with DDL
transactions (e.g. Postgres)
0.7.8
- Fixed South support for custom fields (
DefaultTagsandMACAddressField).
0.7.7
* South migrations supported across the board. For existing installations you
should run::
$ python manage.py migrate APP_NAME 0001 --fake
$ python manage.py migrate APP_NAME
where ``APP_NAME`` is ``activitylog``, ``badges``, ``common``, ``flatpages``,
``profile``, ``score`` or ``tags``.
* uniqueness constraints in ``activitylog.models.Backlink`` and
``activitylog.models.UserAgent`` moved to separate ``hash`` fields to make
MySQL happy. South migrations should handle schema evolution regardless of the
backend you're using.
0.7.6
- Further Django 1.4 compatibility improvements: auto-compelete foreign key mixin works correctly now
0.7.5
* Django 1.4 compatibility improved
0.7.4
-
Django 1.4
USE_TZ = Truecompatibility -
example settings updated to support new Django 1.4 settings
-
Userattribute proxying inProfilemodels rewritten to support all built-in and custom attributes on theUsermodel -
``activitylog.middleware
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
