Skip to main content

Model item always has an owner, and login user can only see owned items.

Project description


Model item always has an owner, and login user can only see owned items.


  • Set item's owner to current user automatically.


pip install django-admin-item-owner






from django.db import models
from item_owner.models import ItemOwnerMixin
from item_owner.models import ItemShareMixin

class Category(ItemOwnerMixin, models.Model):
    title = models.CharField(max_length=32)

    def __str__(self):
        return self.title

class Book(ItemOwnerMixin, ItemShareMixin, models.Model):
    category = models.ForeignKey(Category, on_delete=models.SET_NULL, null=True, blank=True, related_name="books")
    title = models.CharField(max_length=32)

    def __str__(self):
        return self.title


from django.contrib import admin
from django import forms
from item_owner.admin import ItemOwnerMixin
from item_owner.admin import ItemShareMixin
from .models import Category
from .models import Book

class BookInline(ItemOwnerMixin, ItemShareMixin, admin.TabularInline):
    model = Book

class CategoryAdmin(ItemOwnerMixin, admin.ModelAdmin):
    list_display = ["title"]
    inlines = [

class BookAdmin(ItemOwnerMixin, ItemShareMixin, admin.ModelAdmin):
    list_display = ["title"], CategoryAdmin), BookAdmin)


v0.2.0 2020-01-08

  • Add ItemShareMixin for models and admins.

v0.1.0 2019-12-01

  • First release.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-admin-item-owner, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size django-admin-item-owner-0.2.0.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page