File "C:\Users\Aditya\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django_shop-0.10.2-py3.6.egg\shop\models\product.py", line 12, in <module>
from polymorphic.manager import PolymorphicManager
ModuleNotFoundError: No module named 'polymorphic'
我正在尝试使用某些教师的视频制作一个在线商店项目。我是django的新手并且不知道什么似乎是问题。我的models.py文件看起来像这样。我正在使用命令python manage.py makemigrations
from django.db import models
# Create your models here.
from django.core.urlresolvers import reverse
class Category(models.Model):
name=models.Charfield(max_length=200, db_index=True)
slug=models.Slugfield(max_length=200, db_index=True, unique=True)
class Meta:
ordering=('name',)
verbose_name='category'
verbose_name_plural='categories'
def__str__(self):
return self.name
def get_absolute_url(self):
return reverse('shop:product_list_by_category', args=[self.slug])
Class product(models.Model):
category=models.ForeignKey(Category, related_name='products')
name=models.CharField(max_length=200, db_index=True)
slug=models.SlugField(max_length=200, db_index=True)
image=models.ImageField(upload_to'product/%Y/%m/%d',blank=True)
description=models.TextField(blank=True)
price=models.DecimalField(max_digits=10, decimal_places=2)
stock=models.PositiveIntegerField()
available=models.BooleanField(default=True)
created=models.Datetimefield(auto_now_add=True)
updated=models.DatetimeField(auto_now=True)
Class Meta:
ordering=('-created',)
index_togetther=(('id','slug'),)
def__str__(self):
return self.name
def get_absolute_url(self):
return reverse('shop:product_detail', args=[self.id,self.slug)
答案 0 :(得分:1)
pip install django-polymorphic
referece https://github.com/django-polymorphic/django-polymorphic