File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Generated by Django 4.2.20 on 2025-03-20 11:10
2+
3+ from django .db import migrations
4+
5+
6+ def remove_test_model_default_permissions (apps , schema_editor ):
7+ ContentType = apps .get_model ("contenttypes" , "ContentType" )
8+ Permission = apps .get_model ("auth" , "Permission" )
9+ db_alias = schema_editor .connection .alias
10+
11+ try :
12+ test_model_content_type = ContentType .objects .using (db_alias ).get (app_label = "db" , model = "testmodel" )
13+ Permission .objects .using (db_alias ).filter (content_type = test_model_content_type ).delete ()
14+ except ContentType .DoesNotExist :
15+ return
16+
17+
18+ class Migration (migrations .Migration ):
19+ dependencies = [
20+ ("db" , "0001_initial" ),
21+ ]
22+
23+ operations = [
24+ migrations .AlterModelOptions (
25+ name = "testmodel" ,
26+ options = {"default_permissions" : ()},
27+ ),
28+ migrations .RunPython (
29+ code = remove_test_model_default_permissions ,
30+ reverse_code = migrations .RunPython .noop ,
31+ ),
32+ ]
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ class TestModel(models.Model):
66
77 class Meta :
88 db_table = "health_check_db_testmodel"
9+ default_permissions = ()
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ name = "health_check"
7373write_to = " health_check/_version.py"
7474
7575[tool .pytest .ini_options ]
76- addopts = " --nomigrations -- cov --reuse-db --strict-markers --cov-report=xml --cov-report=term --doctest-modules"
76+ addopts = " --cov --strict-markers --cov-report=xml --cov-report=term --doctest-modules"
7777testpaths = [
7878 " tests" ,
7979]
You can’t perform that action at this time.
0 commit comments