from ctypes import DEFAULT_MODE
from django.db import models
from django.db.models.deletion import CASCADE, PROTECT
from django.db.models.expressions import Col
from django.db.models.fields import PositiveSmallIntegerField
from django.utils.translation import pgettext_lazy


class Promotions(models.Model):
    description = models.CharField(max_length=255)
    discount = models.FloatField()


class Collection(models.Model):
    title = models.CharField(max_length=255)


class Product(models.Model):
    title = models.CharField(max_length=255)
    descriptions = models.TextField()
    price = models.DecimalField(max_digits=5, decimal_places=2)
    inventory = models.IntegerField()
    last_update = models.DateTimeField(auto_now=True)
    collection = models.ForeignKey(Collection, on_delete=models.PROTECT)
    promotion = models.ManyToManyField(Promotions, on_delete=models.CASCADE)


class Customer(models.Model):

    MEMBERSHIP_BRONZE = "B",
    MEMBERSHIP_SILEVR = "S",
    MEMBERSHIP_GOLD = "G"
    MEMBERSHIP_CHOICES = [
        ('B', 'Bronze'),
        ('S', 'Silver'),
        ('G', '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):

    PAYMENT_STATUS_PENDING = "P"
    PAYMENT_STATUS_COMPLETE = "C"
    PAYMENT_STATUS_FAILED = "F"

    PEYMENT_STATUS_CHOICES = [
        (PAYMENT_STATUS_PENDING, "Pending"),
        (PAYMENT_STATUS_COMPLETE, "Complete"),
        (PAYMENT_STATUS_FAILED, "Failed")
    ]

    placed_at = models.DateTimeField(auto_now_add=True)
    payment_status = models.CharField(
        max_length=1, choices=PEYMENT_STATUS_CHOICES, 
default=PAYMENT_STATUS_PENDING)
    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.ForeignKey(Customer, on_delete=models.CASCADE)


class Cart(models.Model):
    created_at = models.DateTimeField(auto_now_add=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)


class CartItem(models.Model):
    cart = models.ForeignKey(Cart, on_delete=models.CASCADE)
    product = models.ForeignKey(Product, on_delete=models.CASCADE)
    quantity = models.PositiveSmallIntegerField()



here is my  models.py. 
Vào lúc 22:39:21 UTC+7 ngày Chủ Nhật, 5 tháng 12, 2021, hu3mu...@gmail.com 
đã viết:

> Please, can you take some prints of your models?
>
> Em dom., 5 de dez. de 2021 12:34, Khánh Hoàng <hoangduck...@gmail.com> 
> escreveu:
>
>> Hi everyone, I am new to programming, more than 4 months, I had an issue 
>> when making  migrations for my apps. 
>>
>> I run :" python manage.py makemigrations " and  I got a error.
>>  It said:  TypeError: __init__() got an unexpected keyword argument 'on 
>> delete'
>> I'm Using Django 3.2.9 
>> Can someone explain it for me? And how to fix it.
>>
>> Thanks and Regards,
>> Khanh Hoang
>>
>> -- 
>>
> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/b5adebe5-05b0-4c33-b164-85fda53e13cbn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/b5adebe5-05b0-4c33-b164-85fda53e13cbn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2f5adeeb-91b0-49bb-a012-ba062095c74dn%40googlegroups.com.

Reply via email to