我正在开发我的第一个 Django 应用程序,但遇到了一个奇怪的错误。我查看了它并检查了我正在使用的 Django 文档 1.5.1 版本,它没有说明这个错误。
pat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
DeprecationWarning)
TypeError: __init__() got an unexpected keyword argument 'verify_exists'
我正在使用一个虚拟环境,其中安装了 Django 以及(pip freeze 输出):
Django==1.5.1
argparse==1.2.1
django-db-log==2.2.1
psycopg2==2.4.6
wsgiref==0.1.2
yolk==0.4.3
此外,重要的是要注意我python manage.py syncdb
在停用虚拟环境时尝试运行 - 没有错误。此错误仅在我使用虚拟环境时发生。有任何想法吗?在此先感谢,如果这是一个小问题,我很抱歉,我对 Django 很陌生!
编辑:我发现这看起来很有希望,但通过我唯一的模型,我从不使用 URLField()...
EDIT2:我唯一的models.py:
from django.db import models
class Category(models.Model):
name = models.CharField(max_length=50)
slug = models.SlugField(max_length=50, unique=True, help_text='Unique value for product page URL, created from name.')
description = models.TextField()
is_active = models.BooleanField(default=True)
meta_keywords = models.CharField("Meta Keywords", max_length=255, help_text='Comma-delimited set of SEO keywords for meta tag')
meta_description = models.CharField("Meta description", max_length=255, help_text='Content for description meta tag')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'categories'
ordering = ['-created_at']
verbose_name_plural = 'Categories'
def __unicode__(self):
return self.name
@models.permalink
def get_absolute_url(self):
return ('catalog_category', (), {'category_slug': self.slug})
class Product(models.Model):
name = models.CharField(max_length=255, unique=True)
slug = models.SlugField(max_length=255, unique=True, help_text= 'Unique value for product page URL, create from name.')
brand = models.CharField(max_length=50)
sku = models.CharField(max_length=50)
price = models.DecimalField(max_digits=9, decimal_places=2)
old_price = models.DecimalField(max_digits=9, decimal_places=2, blank=True, default=0.00)
image = models.CharField(max_length=50)
is_active = models.BooleanField(default=True)
is_bestseller = models.BooleanField(default=False)
is_featured = models.BooleanField(default=False)
quantity = models.IntegerField()
description = models.TextField()
meta_keywords = models.CharField(max_length=255, help_text='Comma-delimited set of SEO keywords for meta tag')
meta_description = models.CharField(max_length=255, help_text='Content for description meta tag')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
categories = models.ManyToManyField(Category)
class Meta:
db_table = 'products'
ordering = ['-created_at']
def __unicode__(self):
return self.name
@models.permalink
def get_absolute_url(self):
return('catalog_product', (), {'product_slug': self.slug})
def sale_price(self):
if (self.old_price > self.price):
return self.price
else:
return None