Skip to main content

No frills GenericForeignKeys for your Django Admin

Project description

Django GenericFKAdmin

Using GenericForeignKey in your Django models is cool, the default behavior of Django Admin is not. This package allows you to replace the content_type and object_id fields in your admin forms with a single input that is prefilled with only the models related through GenericRelation fields.

Setup

Install

pip install django-genfkadmin
uv add django-genfkadmin

Usage

Using this package is pretty simple.

  1. Create a subclass of GenericFKModelForm for your model.
  2. Create a subclass of GenericFKAdmin for your model.
  3. ???
  4. Profit!

e.g. in your admin.py

from genfkadmin.admin import GenericFKAdmin
from genfkadmin.forms import GenericFKModelForm


class PetAdminForm(GenericFKModelForm):

    class Meta:
        model = Pet
        fields = "__all__"


@admin.register(Pet)
class PetAdmin(GenericFKAdmin):
    form = PetAdminForm

example

A complete example django app exists in this repository at here

Roadmap

  1. Implement a filtering callback to further restrict the set of options available in the selector
  2. Stacked and Tabular Inline support.

Project details


Download files

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

Source Distribution

django_genfkadmin-0.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_genfkadmin-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file django_genfkadmin-0.1.0.tar.gz.

File metadata

  • Download URL: django_genfkadmin-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for django_genfkadmin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 23fa8425f139cadb3bebbdd35e4ed13d14c91c0be5d2a0d0e8d35a1cf38d028c
MD5 74e17a26fe2bbd06ddfdb9e33e4aae27
BLAKE2b-256 92e1905b023dd12f17952283704461e8e04781c870343883c8db1d145c631e87

See more details on using hashes here.

File details

Details for the file django_genfkadmin-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_genfkadmin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce4b83becd6b3db31f7e56501447d48920ffbeacddaf032e8d6ff6eeef9627eb
MD5 fc5fbf1147d5ddb5d09b7d26be234c19
BLAKE2b-256 3ce4a587cc7841f67c0306540b8a688befe0c38abd133690436059f394589952

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page