简体   繁体   English

为什么在运行manage.py validate时出现错误?

[英]Why do I get error when i run manage.py validate?

I use Python 3.3 Django 1.7 and Windows OS 我使用Python 3.3 Django 1.7和Windows OS

this is my models.py file and below it is the error snippet when I run the interpreter. 这是我的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.

this is my models.py file. 这是我的models.py文件。 what is wrong with this code? 此代码有什么问题? when i run the interpreter the errors are as follows 当我运行解释器时,错误如下


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.

该参数称为max_length

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试运行 manage.py runserver 时出现错误 - Get an error when I try to run manage.py runserver 为什么我在 manage.py makemigrations 上出现语法错误? - why do i get syntax error on manage.py makemigrations? 当我运行./manage.py运行服务器时,我得到错误ImportError:没有名为celery的模块 - When I run ./manage.py run server I get the error ImportError: No module named celery 当我在models.py中的python django中运行此命令python manage.py makemigrations博客时出错 - Error when I run this command python manage.py makemigrations blog in python django in models.py 为什么我在安装 Django 2.2 时无法运行“manage.py runserver”? - Why can't I run “manage.py runserver” when I install Django 2.2? 当我运行 python manage.py makemigrations 时出现此错误 - I have got this error when i run python manage.py makemigrations 为什么当我运行 python manage.py runserver 时有两个进程 - why there are two process when i run python manage.py runserver 如何解决 manage.py 中的这个语法错误? - How do I solve this syntax error in manage.py? 当我这样做时没有任何反应:python manage.py 命令 - Nothing happens when I do: python manage.py command 为什么在此命令python manage.py shell中出现错误? - Why do I have Error In This Command python manage.py shell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM