Skip to content

Commit

Permalink
change ForeignKey with unique=True to OneToOneField
Browse files Browse the repository at this point in the history
  • Loading branch information
brad committed Nov 3, 2016
1 parent 4019b95 commit bf2ae48
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions misfitapp/migrations/0006_fkunique_to_onetoone
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-03 16:26
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('misfitapp', '0005_help_text'),
]

operations = [
migrations.AlterField(
model_name='profile',
name='user',
field=models.OneToOneField(help_text=b"The profile's user", on_delete=django.db.models.deletion.CASCADE, related_name='misfit_profile', to=settings.AUTH_USER_MODEL),
),
]
6 changes: 4 additions & 2 deletions misfitapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ class Profile(MisfitModel):
"""
GENDER_TYPES = (('male', 'male'), ('female', 'female'))

user = models.ForeignKey(
UserModel, unique=True, help_text="The profile's user")
user = models.OneToOneField(
UserModel,
related_name='misfit_profile',
help_text="The profile's user")
email = models.EmailField(null=True, blank=True, help_text='Email address')
birthday = models.DateField(help_text="The user's birth date")
gender = models.CharField(
Expand Down

0 comments on commit bf2ae48

Please sign in to comment.