-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circular dependency error #110
Comments
Hmm, this seems like a circular dependency error in your code. Can you share more about your project's environment? |
Django==4.0.1 python 3-alpine docker container from django.db import models
# Create your models here.
from django.db.models import Model
class Promotions(Model):
description = models.CharField(max_length=255)
discount = models.FloatField()
class Collection(Model):
title = models.CharField(max_length=255)
featured_product = models.ForeignKey(
'Product', on_delete=models.SET_NULL, null=True, related_name='+')
class Product(Model):
title = models.CharField(max_length=255)
description = models.TextField()
slug = models.SlugField()
price = models.DecimalField(max_digits=10, decimal_places=2)
inventory = models.IntegerField()
collection = models.ForeignKey(
Collection, on_delete=models.PROTECT)
promotions = models.ManyToManyField(Promotions)
last_update = models.DateTimeField(auto_now=True)
class Customer(Model):
BRONZE = 'B'
SILVER = 'S'
GOLD = 'G'
MEMBESHIP_TYPES = [(BRONZE, 'Bronze'), (SILVER, 'Silver'), (GOLD, 'Gold')]
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
email = models.EmailField(unique=True)
phone = models.CharField(max_length=255)
date_of_birth = models.DateField()
membership = models.CharField(
max_length=1, choices=MEMBESHIP_TYPES, default=BRONZE)
class Order(Model):
PENDING = 'P'
COMPLETED = 'C'
FAILED = 'F'
STATUSES = [(
PENDING, 'Pending'), (COMPLETED, 'Completed'), (FAILED, 'Failed')]
placed_at = models.DateTimeField(auto_now_add=True)
customer = models.ForeignKey(Customer, on_delete=models.PROTECT)
payment_status = models.CharField(
max_length=1, choices=STATUSES, default=PENDING)
class OrderItem(Model):
order = models.ForeignKey(Order, on_delete=models.PROTECT)
product = models.ForeignKey(Product, on_delete=models.PROTECT)
quantity = models.IntegerField()
price = models.DecimalField(max_digits=10, decimal_places=2)
class Address(Model):
street = models.CharField(max_length=255)
address = models.CharField(max_length=255)
city = models.CharField(max_length=255)
customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
class Cart(Model):
created_at = models.DateTimeField(auto_now_add=True)
customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
class CartItem(Model):
cart = models.ForeignKey(Cart, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
quantity = models.IntegerField() when i disable this line the seeding works class Collection(Model):
title = models.CharField(max_length=255)
# featured_product = models.ForeignKey(
# 'Product', on_delete=models.SET_NULL, null=True, related_name='+') |
I get this circular dependency error while seeding, is there any option to fix this?
The text was updated successfully, but these errors were encountered: