from django.db import models
class products(models.Model): #Table name, has to wrap models.Model to get the functionality of Django.
name = models.CharField(max_length=200, unique=True) #Like a VARCHAR field
description = models.TextField() #Like a TEXT field
price = models.IntegerField()
def __unicode__(self): #Tell it to return as a unicode string (The name of the to-do item) rather than just Object.
return self.name
class categories(models.Model):
我是 python 新手,我正在尝试创建一个电子商务商店。正如您在上面看到的,我创建了 products 类,但是在 Categories 类中,我需要包含我创建的所有产品属于某个类别。我不知道该怎么做。