Skip to content

Commit e8f7ab8

Browse files
committed
BE: Add migration to create anonymous user
1 parent 5f3b230 commit e8f7ab8

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 5.1.5 on 2025-02-26 00:27
2+
3+
from django.db import migrations
4+
from django.contrib.auth import get_user_model
5+
6+
def create_anonymous_user(apps, schema_editor):
7+
User = get_user_model()
8+
if not User.objects.filter(username="anonymous").exists():
9+
User.objects.create(
10+
username="anonymous",
11+
)
12+
13+
14+
class Migration(migrations.Migration):
15+
16+
dependencies = [
17+
('users', '0002_create_superuser'),
18+
]
19+
20+
operations = [
21+
migrations.RunPython(create_anonymous_user),
22+
]

0 commit comments

Comments
 (0)