Some admin and related name stuff for user profiles
authorDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 4 Mar 2022 16:14:28 +0000 (11:14 -0500)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 4 Mar 2022 16:14:28 +0000 (11:14 -0500)
src/user_profile/admin.py
src/user_profile/migrations/0002_related_name.py [new file with mode: 0644]
src/user_profile/models.py

index 8c38f3f..44bca6e 100644 (file)
@@ -1,3 +1,7 @@
 from django.contrib import admin
 
-# Register your models here.
+from . import models
+
+class UserProfileAdmin(admin.ModelAdmin):
+    pass
+admin.site.register(models.UserProfile, UserProfileAdmin)
diff --git a/src/user_profile/migrations/0002_related_name.py b/src/user_profile/migrations/0002_related_name.py
new file mode 100644 (file)
index 0000000..d79e0d2
--- /dev/null
@@ -0,0 +1,21 @@
+# Generated by Django 4.0.3 on 2022-03-04 16:13
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('user_profile', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='userprofile',
+            name='user',
+            field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL),
+        ),
+    ]
index a98a009..7aeb9bf 100644 (file)
@@ -4,7 +4,11 @@ from django.db.models.signals import post_save
 from django.dispatch import receiver
 
 class UserProfile(models.Model):
-    user = models.OneToOneField(User, on_delete=models.CASCADE)
+    user = models.OneToOneField(
+        User,
+        on_delete=models.CASCADE,
+        related_name='profile',
+    )
     notes = models.TextField(blank=True, null=True)
 
     def __str__(self):