Skip to main content

Django Admin Related

this project makes it impossible for the user to delete objects that contain other objects related by django admin.

Obs: this project works only in django admin

Install:

pip install django-admin-related

Usage:

  1. Add to your INSTALLED_APPS, in settings.py:

    INSTALLED_APPS = [  
        ...
        'django_admin_related',
        ...
    ]  
    
  2. Create admin for your model:

    from django.contrib.admin import register
    from django_admin_related.admin import VerifyRelated
    
    @register(YouModel)
    class YouModelAdmin(VerifyRelated):
        """
            from best performance use `verify_related_fields`
            because this check all fields is a point to other model
            and `verify_related_fields` is a direct way.
        """
        pass
    
  3. Test:

     try this: create a simple model, and simple related model, and exclude a first model.
    

Advanced:

  1. if you need to specify relationships, you can do so :
    from django.contrib.admin import register
    from django_admin_related.admin import VerifyRelated
    
    @register(YouModel)
    class YouModelAdmin(VerifyRelated):
        """
            from best performance use `verify_related_fields`
            because this check all fields is a point to other model
            and `verify_related_fields` is a direct way.
        """
        verify_related_fields = ('field', 'field2', ...)
    

Metadata

Release files for django-admin-related 0.2

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-admin-related 0.2
File Size Uploaded
django-admin-related-0.2.tar.gz 6.0 kB Details

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file

0.1.1

1 release file

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