# Remove Django Permissions Default

**URL:** <https://forum.djangoproject.com/t/remove-django-permissions-default/31459>\
**Category:** Using the ORM\
**Created:** [May 23, 2024, 3:08pm UTC](https://forum.djangoproject.com/t/remove-django-permissions-default/31459 "2024-05-23T15:08:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![williank](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/williank/32/21505_2.png) [@williank](https://forum.djangoproject.com/u/williank)\
**Post date:** [May 23, 2024, 3:08pm UTC](https://forum.djangoproject.com/t/remove-django-permissions-default/31459/1 "2024-05-23T15:08:36Z")

</div>

My system should not have model-based permissions, how do I disable the default permissions (add, edit, delete, view) that are created for each model in the first migration?

I need to disable this, as I cannot actually have permissions linked to the model.

---

<div class="post-metadata">

**Author:** ![leandrodesouzadev](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/leandrodesouzadev/32/8981_2.png) [@leandrodesouzadev](https://forum.djangoproject.com/u/leandrodesouzadev)\
**Post date:** [May 23, 2024, 4:04pm UTC](https://forum.djangoproject.com/t/remove-django-permissions-default/31459/2 "2024-05-23T16:04:46Z")

</div>

This is added by a post\_migrate signal.  
You can disable this in two ways:

- Remove `django.contrib.auth` from your installed apps (some things may stop working)
- Unregister the post\_migrate signal from one of your apps

For the second option, here’s an example…  
I have created a IAM application because i wanted to have more control about the accounts and login proccess, as well as the permissions, for me it was crucial that the migrations were generated on a specific language, and by default they are generated on english. So to accomplish this i had to disconnect the default signal connected to the post\_migrate signal, and register my own.  
I believe that for your use case you only need to disconnect the signal.

```python
from django.apps import AppConfig
from django.db.models.signals import post_migrate

class IAMConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "iam"

    def ready(self) -> None:
        from iam.post_migrate import create_permissions

        post_migrate_disconnected = post_migrate.disconnect(
            receiver=None,
            sender=None,
            dispatch_uid="django.contrib.auth.management.create_permissions",
        )
        if not post_migrate_disconnected:
            raise ValueError(
                "Expected to disconnect the post_migrate signal, in order to reapply it"
            )

        post_migrate.connect(
            receiver=create_permissions,
            dispatch_uid="django.contrib.auth.management.create_permissions",
        )

```

Hope this helps, cheers.

---

<div class="post-metadata">

**Author:** ![williank](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/williank/32/21505_2.png) [@williank](https://forum.djangoproject.com/u/williank)\
**Post date:** [May 24, 2024, 1:01am UTC](https://forum.djangoproject.com/t/remove-django-permissions-default/31459/3 "2024-05-24T01:01:15Z")

</div>

I need permissions to be based on each view. Rather than being model-based.

Does anyone have any idea how they can do this?

The default is that with each new model in the first migration, permissions are created. However, not every view has a mOdel.

That’s why I wanted permissions to be created automatically for each View. Example below

```
permission_required = {
    'GET': ['app.view_myview'],
    'POST': ['app.add_myview'],
    'PUT': ['app.change_myview'],
    'PATCH': ['app.change_myview'],
    'DELETE': ['app.delete_myview'],
}

```

Remembering that, all isos based on Views.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 25, 2024, 1:45am UTC](https://forum.djangoproject.com/t/remove-django-permissions-default/31459/4 "2024-05-25T01:45:39Z")

</div>

It appears you might have an incomplete understanding of how the current permissions system works and how it’s intended to be used.

Permissions aren’t _tied_ to models. Yes, permissions are associated with models, but that’s _primarily_ for the benefit of the admin app. You are free to use permissions as you see fit.

Read the _complete_ threads at [Conditional content rendering, based on permissions](https://forum.djangoproject.com/t/conditional-content-rendering-based-on-permissions/21865) for a perspective on this.

Your views _check_ what permissions are granted to the user, the permissions aren’t “associated” with the view. (In most cases, a user is going to need to use more than one view - you may, or may not, want to use the same permission to grant access to more than one view.)

The Django permission system can effectively be used as the foundation of a “Role-based” access system, where the Group model is used for the roles, and the permissions granted to those groups identify what actions the members of that group can perform.

---

<div class="post-metadata">

**Author:** ![williank](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/williank/32/21505_2.png) [@williank](https://forum.djangoproject.com/u/williank)\
**Post date:** [May 25, 2024, 2:51am UTC](https://forum.djangoproject.com/t/remove-django-permissions-default/31459/5 "2024-05-25T02:51:17Z")

</div>

Given that my frontend is decoupled from django… For this reason, permissions cannot be associated with models. In fact, I need to create custom permissions without any links or dependencies on the Models. So if different from the django pattern that creates 4 permissions on the first migration of each template I could change it to create whenever a new view was added, it would be very interesting for me. In fact I don’t use this django admin, but I want to use django auth…

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 25, 2024, 3:28am UTC](https://forum.djangoproject.com/t/remove-django-permissions-default/31459/6 "2024-05-25T03:28:27Z")

</div>

> [@williank](#):
>
> Given that my frontend is decoupled from django…

This has nothing to do with anything related to this. You are creating constraints and limitations for yourself that don’t exist.

> [@williank](#):
>
> In fact, I need to create custom permissions without any links or dependencies on the Models.

Please read the complete thread I referenced for you. You’ll see that the association between a permission and a model is not a limitation, constraint, or restriction for what you’re trying to do.

If you want to effectively use the Django permission system, you’ll want to change your perspective on what those permissions mean and how they’re used by the views.

The phrase I use frequently around here is “Don’t fight the framework”. Do things the way that Django wants you to do them, don’t try to change Django to match whatever your current “mental model” may be.
