Browse Source

Should be one-to-one relationship.

feature/python-error-tracking
Drew Larson 9 years ago
parent
commit
34088316ee
  1. 25
      bikeshop_project/core/migrations/0013_auto_20160531_0236.py
  2. 14
      bikeshop_project/core/models.py

25
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'),
),
]

14
bikeshop_project/core/models.py

@ -16,6 +16,13 @@ class Membership(models.Model):
blank=True, blank=True,
null=True null=True
) )
payment = models.OneToOneField(
'Payment',
on_delete=models.CASCADE,
related_name='membership',
blank=False,
null=True
)
class Payment(models.Model): class Payment(models.Model):
@ -28,13 +35,6 @@ class Payment(models.Model):
) )
type = models.CharField(max_length=12, choices=payment_choices) type = models.CharField(max_length=12, choices=payment_choices)
created_at = models.DateTimeField(auto_now_add=True) 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): class Visit(models.Model):

Loading…
Cancel
Save