我正在开发我的第一个 Django 应用程序,但遇到了一个奇怪的错误。我看了looked it up并检查了我正在使用的版本 1.5.1 的 Django 文档,它没有说明这个错误。
pat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
DeprecationWarning)
TypeError: __init__() got an unexpected keyword argument 'verify_exists'
我使用的是虚拟环境,其中安装了 Django 以及(pip 卡住输出):
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 还很陌生!
编辑:我找到了 this这看起来很有希望,但通过我唯一的模型来看,我从不使用 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
请您参考如下方法:
我想我找到了原因,查看您项目中安装的应用程序。我发现 django-db-log 使用 models.URLField(verify_exists=False, null=True, blank=True),它在新版本中已被弃用。
他们的项目还没有升级,所以也许你可以在他们的项目中拉一个请求或者卸载那个应用
更新:来自@NathanVillaescusa
from django.utils.hashcompat import md5_constructor //deprecated also
