This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
********
django-author
********
.. image:: https://travis-ci.org/lambdalisue/django-author.svg
:target: https://travis-ci.org/lambdalisue/django-author
.. image:: https://coveralls.io/repos/github/lambdalisue/django-author/badge.svg?branch=master
:target: https://coveralls.io/github/lambdalisue/django-author?branch=master

Update author and updated_by fields of models automatically

This library is used for updating ``author`` and ``updated_by`` fields automatically
with ``request.user`` when the model has created/changed.

Also if you are too lazy to write ``author = models.ForeignKey(User, _('author'), related_name ...)`` to every model,
just add ``@with_author`` decorator to the top of class makes you happy.


Install
==============
This library is on PyPI so you can install it with::

pip install django-author

or from github::

pip install git+https://github.com/lambdalisue/django-author.git


Usage
==========

1. Add 'author' to your ``INSTALLED_APPS`` on settings.py

2. Add 'author.middlewares.AuthorDefaultBackendMiddleware' to your ``MIDDLEWARE_CLASSES``
if you use default author backend

3. Add ``author`` and ``updated_by`` field to models which you want to have ``author`` and ``updated_by`` fields manually
or use ``@with_author`` decorator like below::

from django.db import models
from author.decorators import with_author

@with_author
class Entry(models.Model):
title = models.CharField('title', max_length=50)
body = models.TextField('body')

4. Done. Now you have automatically updated ``author`` and ``updated_by`` fields

If you are in truble, see ``author_test`` directory for usage sample.


Settings
================

AUTHOR_BACKEND
Class or string path of backend. the backend is used to determine user when object is created/updated.

AUTHOR_CREATED_BY_FIELD_NAME
A name of field. the setting also interfer the name of field created by ``@with_author`` decorator. default is 'author'

AUTHOR_UPDATED_BY_FIELD_NAME
A name of field. the setting also interfer the name of field created by ``@with_author`` decorator. default is 'updated_by'

AUTHOR_DO_NOT_UPDATE_WHILE_USER_IS_NONE
Do not update ``author`` or ``updated_by`` field when detected user is None. default is True

AUTHOR_MODELS
Check signals for only these models. default is None

AUTHOR_IGNORE_MODELS
Do not check signals for these models. default is ['auth.user', 'auth.group', 'auth.permission', 'contenttype.contenttype']


Backend
==============
The default backend use ``thread_locals`` storategy to get current request in signal call.

If you want to change the strategy or whatever, create your own backend.

A backend is a class which have ``get_user`` method to determine current user.

AuthorDefaultBackend
Default backend. This backend return None when no request found or AnonymousUser create/update object.

AuthorSystemUserBackend
System user backend. This backend return system user when no request found or AnonymousUser create/update object.

system user is determined with ``get_system_user`` method and default is ``User.objects.get(pk=1)``
Release History

Release History

0.4.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1rc2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-author-0.4.4.tar.gz (18.1 kB) Copy SHA256 Checksum SHA256 Source Jun 26, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting