diff --git a/bikeshop_project/core/migrations/0013_auto_20160531_0236.py b/bikeshop_project/core/migrations/0013_auto_20160531_0236.py new file mode 100644 index 0000000..5dae435 --- /dev/null +++ b/bikeshop_project/core/migrations/0013_auto_20160531_0236.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-05-31 02:36 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0012_auto_20160531_0234'), + ] + + operations = [ + migrations.RemoveField( + model_name='payment', + name='membership', + ), + migrations.AddField( + model_name='membership', + name='payment', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='membership', to='core.Payment'), + ), + ] diff --git a/bikeshop_project/core/models.py b/bikeshop_project/core/models.py index 33bf3a2..deeae3e 100644 --- a/bikeshop_project/core/models.py +++ b/bikeshop_project/core/models.py @@ -16,6 +16,13 @@ class Membership(models.Model): blank=True, null=True ) + payment = models.OneToOneField( + 'Payment', + on_delete=models.CASCADE, + related_name='membership', + blank=False, + null=True + ) class Payment(models.Model): @@ -28,13 +35,6 @@ class Payment(models.Model): ) type = models.CharField(max_length=12, choices=payment_choices) created_at = models.DateTimeField(auto_now_add=True) - membership = models.ForeignKey( - 'Membership', - on_delete=models.CASCADE, - related_name='payments', - blank=False, - null=True - ) class Visit(models.Model):