Skip to main content

Custom fieldset settings for django admin with groups access

# models.py
import custom_fields

class Test(models.Model):
    class FieldCategory(custom_fields.CategoryChoices):
        category_a = custom_fields.CategoryLabel('category_a') # 1
        category_b = custom_fields.CategoryLabel(
            'category_b', 
            hidden_for_superuser=True
            allowed_groups=['Group names who can see and edit']
        ) 

    test_row_1 = custom_fields.CharField(max_length=40, category=FieldCategory.category_a)
    test_row_2 = custom_fields.CharField(max_length=40, category=FieldCategory.category_a)

    test_row_3 = custom_fields.CharField(max_length=40, category=FieldCategory.category_b)
    test_row_4 = custom_fields.CharField(max_length=40, category=FieldCategory.category_b)


# admin.py
import custom_fields

class TestAdmin(custom_fields.ModelAdminMixin, admin.ModelAdmin):
    readonly_fields = ("extra_field", )

    extra_fieldsets = {
        Test.FieldCategory.category_a: [
            "extra_field", # For extra fields outside of model
        ]
    } # optional

    def extra_field(self, obj: Test):
        return f"#{obj.id}"      

Metadata

Release files for django-custom-fieldsets 0.0.1

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

Source distribution (sdist)

Source distribution for django-custom-fieldsets 0.0.1
File Size Uploaded Provenance
django-custom-fieldsets-0.0.1.tar.gz 12.6 kB Without provenance Details

Release files / django-custom-fieldsets-0.0.1.tar.gz

Download URL django-custom-fieldsets-0.0.1.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e11d6a4bcdf77f0fbbfeeb805f6b5382ce69bcdd19ac76891c64bd7ce65aa3fc
BLAKE2b-256 checksum
How to use checksums
9f9ebaa287dba53647ac1b5362071330d2a9bd2c2f7cd4f1e8b8f9b99ab35c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Security for django-custom-fieldsets 0.0.1

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.

Release history Release notifications | RSS feed

This release

0.0.1 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