Python 调用';syncdb';
我正在开发我的第一个Django应用程序,我遇到了一个奇怪的错误。我查看并检查了我正在使用的Django文档1.5.1版,它没有说明这个错误Python 调用';syncdb';,python,django,virtualenv,Python,Django,Virtualenv,我正在开发我的第一个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_exis
pat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
DeprecationWarning)
TypeError: __init__() got an unexpected keyword argument 'verify_exists'
我正在使用一个虚拟环境,其中安装了Django以及(pip冻结输出):
另外,需要注意的是,当我停用虚拟环境时,我尝试运行了python manage.py syncdb
,但没有出现错误。此错误仅在使用虚拟环境时发生。有什么想法吗?提前谢谢,如果这是一个nooby问题,我深表歉意,我是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
我想我找到了原因,看看你的项目中安装的应用程序。我发现
django db log
使用models.URLField(verify_exists=False,null=True,blank=True)
,这在新版本中已被弃用
他们的项目还没有升级,所以也许你可以在他们的项目中拉一个请求,或者卸载那个应用程序
更新:来自@NathanVillaescusa
from django.utils.hashcompat import md5_constructor //deprecated also
您正在将
verify\u exists
参数传递给不接受它的类构造函数。你能包括一些你项目的源代码吗?pat.py第9行的代码是什么?安装的第三方应用程序如何?您是否已将其升级到最新版本?Catharine提出了一个很好的观点。我猜django db log是罪魁祸首,因为它看起来并没有在3年内更新。目前,他们有问题要解决,所以如果您请求升级版本,他们无法立即进行升级。django db log
也是弃用警告的原因:@NathanVillaescusa是的,这是第一个错误。下一个错误是关于验证是否存在。更好的方法是卸载该应用程序并替换它谢谢!我最初认为djangodblog是最新的(这是因为当我更新它时,没有发现任何更新)。如果距离上次提交已有3年时间,则有意义。
from django.utils.hashcompat import md5_constructor //deprecated also