运行manage.py validate时为什么会出错?

时间:2014-11-15 17:38:38

标签: python django

我使用的是Python 3.3 Django 1.7 和Windows操作系统

这是我的models.py文件,下面是我运行解释器时的错误代码段。

from django.db import models


class Publisher(models.Model):
        name = models.CharField(max_length=30)
        address = models.CharField(max_length=50)
        city = models.CharField(max_length=60)
        state_province = models.CharField(max_length=30)
        country = models.CharField(max_length=50)
        website = models.URLField()

class Author(models.Model):
        salutation = models.CharField(max_length=10)
        first_name = models.CharField(max_length=30)
        last_name = models.CharField(max_length=40)
        email = models.EmailField()
        headshot = models.ImageField(upload_to='/tmp')

class Book(models.Model):
        title = models.CharField(max_length=100)
        authors = models.ManyToManyField(Author)
        publisher = models.ForeignKey(Publisher)
        publication_date = models.DateField()

# Create your models here.

  

这是我的models.py文件。这段代码有什么问题?当我跑   解释器错误如下


Traceback (most recent call last):
  File "C:\Python33\Scripts\mysite\books\models.py", line 3, in <module>
    class Publisher(models.Model):
  File "C:\Python33\Scripts\mysite\books\models.py", line 4, in Publisher
    name = models.CharField(max_length=30)
  File "C:\Python33\lib\site-packages\django\db\models\fields\__init__.py", line 1012, in __init__
    super(CharField, self).__init__(*args, **kwargs)
  File "C:\Python33\lib\site-packages\django\db\models\fields\__init__.py", line 146, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "C:\Python33\lib\site-packages\django\conf\__init__.py", line 46, in __getattr__
    self._setup(name)
  File "C:\Python33\lib\site-packages\django\conf\__init__.py", line 40, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

1 个答案:

答案 0 :(得分:2)

该参数称为max_length