TypeError: ForeignKey(<class 'itertools.product'>) недействителен [закрыто]

Я новичок в Python / Django. Я не могу выполнить ни одной команды, и терминал каждый раз выдает одну и ту же ошибку. Я хочу создать миграцию и написать в терминале python manage.py makemigrations, но это не сработало. как я могу решить эту проблему

моя модель выглядит следующим образом

from itertools import product
from tkinter import CASCADE
from django.db import models

class Promotion(models.Model):
desciption = models.CharField(max_length=255)
discount = models.FloatField()

class Collection(models.Model):
title = models.CharField(max_length=255)
featured_product = models.ForeignKey(product, on_delete=models.SET_NULL, null=True,related_name='+')

class Product (models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
price = models.DecimalField(max_digits=6, decimal_places=2)
last_update = models.DateTimeField(auto_now=True)
collection = models.ForeignKey(Collection, on_delete=models.PROTECT)
promotions = models.ManyToManyField(Promotion)

class Customer (models.Model):
MEMBERSHIP_BRONZE = 'B'
MEMBERSHIP_SILVER = 'S'
MEMBERSHIP_GOLD = 'G'

MEMBERSHIP_CHOICES = [
    (MEMBERSHIP_BRONZE,'Bronze',
    MEMBERSHIP_SILVER, 'Silver',
    MEMBERSHIP_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)
birth_date = models.DateField(null=True)
membership = models.CharField(max_length=1,choices=MEMBERSHIP_CHOICES,default=MEMBERSHIP_BRONZE)

class Order(models.Model):
PENDING = 'P'
COMPLETE = 'C'
FAILED = 'F'

PAYMENT_CHOICES = [
    (PENDING, 'Pending',
    COMPLETE, 'Complete',
    FAILED, 'Failed')

]
payment_status = models.CharField(max_length=1,choices=PAYMENT_CHOICES)
placed_at = models.DateTimeField(auto_now_add=True)
customer = models.ForeignKey(Customer,on_delete=models.PROTECT)

class Address(models.Model):
street = models.CharField(max_length=255)
city = models.CharField(max_length=255)
customer = models.OneToOneField(Customer,on_delete=models.CASCADE,primary_key=True)


class OrderItem(models.Model):
    order = models.ForeignKey(Order,on_delete=models.PROTECT)
    product = models.ForeignKey(Product,on_delete=models.PROTECT)
    quantity = models.PositiveSmallIntegerField()
    unit_price = models.DecimalField(max_digits=6,decimal_places=2)

когда я пишу в терминале

python manage.py makemigrations

появляется эта ошибка

Traceback (most recent call last):
File "/Users/raghad/.local/share/virtualenvs/storefront1-cc5vL6z-/lib/python3.9/site-packages/django/db/models/fields/related.py", line 937, in __init__
to._meta.model_name
AttributeError: type object 'itertools.product' has no attribute '_meta'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/raghad/Desktop/storefront1/manage.py", line 22, in <module>
 main()
File "/Users/raghad/Desktop/storefront1/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/raghad/.local/share/virtualenvs/storefront1-cc5vL6z-/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/Users/raghad/.local/share/virtualenvs/storefront1-cc5vL6z-/lib/python3.9/site-packages/django/core/management/__init__.py", line 420, in execute
 django.setup()
File "/Users/raghad/.local/share/virtualenvs/storefront1-cc5vL6z-/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
 apps.populate(settings.INSTALLED_APPS)
File "/Users/raghad/.local/share/virtualenvs/storefront1-cc5vL6z-/lib/python3.9/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
 File "/Users/raghad/.local/share/virtualenvs/storefront1-cc5vL6z-/lib/python3.9/site-packages/django/apps/config.py", line 269, in import_models
 self.models_module = import_module(models_module_name)
File "/Users/raghad/opt/anaconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
 return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
 File "<frozen importlib._bootstrap_external>", line 850, in exec_module
 File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/Users/raghad/Desktop/storefront1/store/models.py", line 11, in <module>
class Collection(models.Model):
File "/Users/raghad/Desktop/storefront1/store/models.py", line 13, in Collection
    featured_product = models.ForeignKey(product, on_delete=models.SET_NULL, null=True,related_name='+')
 File "/Users/raghad/.local/share/virtualenvs/storefront1-cc5vL6z-/lib/python3.9/site-packages/django/db/models/fields/related.py", line 940, in __init__
raise TypeError(
TypeError: ForeignKey(<class 'itertools.product'>) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string 'self'
Вернуться на верх