Skip to main content

django-authorship

https://gitlab.com/django-authorship/django-authorship/badges/main/pipeline.svg https://gitlab.com/django-authorship/django-authorship/badges/main/coverage.svg Documentation Status

A set of Django mixins to easily record authorship information for your models.

Features

  • Base model allows easy recording of authorship information.

  • Integration with Django’s class-based views and forms.

  • Integration with Django’s admin.

Documentation

The full documentation is at https://django-authorship.readthedocs.io/

Quickstart

Install django-authorship using the installation instructions found in the project documentation.

Build a model based on authorship.models.Authorship to record authorship information on it:

from authorship.models import Authorship

class MyModel(Authorship):

    pass

This adds created_by, created_at, updated_by, and updated_at to your model.

Pass a user into calls to .save() to record which user changed the object:

example = MyModel()
example.save(user=request.user)

If you need to update model data and there’s no direct link to a website user, generate and use a site-wide ‘generic’ user.:

from authorship.models import get_website_user

example = MyModel()
example.save(user=get_website_user())

If you wish to automatically record authorship information for changes made in the Django admin, use authorship.admin.AuthorshipMixin.:

from authorship.admin import AuthorshipMixin
from django.contrib import admin

from .models import MyModel

@admin.register(MyModel)
class MyModelAdmin(AuthorshipMixin, admin.ModelAdmin):

    pass

If you wish to integrate with django.forms.ModelForm, use authorship.forms.AuthorshipMixin and authorship.views.AuthorshipMixin.

In your forms.py:

from authorship.forms import AuthorshipMixin
from django import forms

from .models import MyModel

class MyModelForm(forms.ModelForm):

    class Meta(object):
        model = MyModel

In your views.py:

from authorship.views import AuthorshipMixin
from django.views.generic import CreateView

from .forms import MyModelForm
from .models import MyModel

class MyModelCreateView(AuthorshipMixin, CreateView):

    form_class = MyModelForm

MyModelCreateView will now automatically pass request.user through to MyModelForm, which will pass it through to the model’s save() method.

Credits

See AUTHORS.rst.

Metadata

Release files for django-authorship 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for django-authorship 2.0.0
File Interpreter ABI Platform
django_authorship-2.0.0-py3-none-any.whl Python 3 none any Details

Release files / django_authorship-2.0.0-py3-none-any.whl

Download URL django_authorship-2.0.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c80de3c6d5ee81bb7f85934bfc01a36e1269e7f33795b9301775e90152d3d36
BLAKE2b-256 checksum
How to use checksums
a48a43cdb7ed7e7df5aa3f2040a09b618cd76e0feb6143710930e5b624beabc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Security for django-authorship 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page