From: David Kerkeslager Date: Fri, 4 Mar 2022 16:14:28 +0000 (-0500) Subject: Some admin and related name stuff for user profiles X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=6f15a6fa068d5e0026c59e63e48bb7eb18855115;p=climbing.kerkeslager.com Some admin and related name stuff for user profiles --- diff --git a/src/user_profile/admin.py b/src/user_profile/admin.py index 8c38f3f..44bca6e 100644 --- a/src/user_profile/admin.py +++ b/src/user_profile/admin.py @@ -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 index 0000000..d79e0d2 --- /dev/null +++ b/src/user_profile/migrations/0002_related_name.py @@ -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), + ), + ] diff --git a/src/user_profile/models.py b/src/user_profile/models.py index a98a009..7aeb9bf 100644 --- a/src/user_profile/models.py +++ b/src/user_profile/models.py @@ -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):