18 lines
624 B
Python
18 lines
624 B
Python
|
|
from django.db.models import Q
|
|
from django.core.management.base import BaseCommand
|
|
from django.contrib.auth.models import Permission
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
def handle(self, *args, **options):
|
|
content_types = ContentType.objects.filter(
|
|
Q(app_label='admin', model='logentry') |
|
|
Q(app_label='auth', model='permission') |
|
|
Q(app_label='sessions', model='session') |
|
|
Q(app_label='contenttypes', model='contenttype')
|
|
)
|
|
Permission.objects.filter(content_type__in=content_types).delete()
|