###前提・実現したいこと
Djangogirlsというサイトのチュートリアルに従いブログの作成をしていたところ、models.pyの編集したところでエラー出てしまい困っています。お助け頂きたいです。
■ チュートリアル
https://djangogirlsjapan.gitbooks.io/workshop_tutorialjp/content/how_the_internet_works/index.html
###発生している問題・エラーメッセージ
Traceback (most recent call last): File "/Users/you/djangogirls5/blog/models.py", line 8, in <module> class Post(models.Model): File "/Users/you/djangogirls5/blog/models.py", line 9, in Post author = models.ForeignKey('auth.User') File "/Library/Python/2.7/site-packages/django/db/models/fields/related.py", line 846, in __init__ to, on_delete, from_fields=['self'], to_fields=[to_field], **kwargs) File "/Library/Python/2.7/site-packages/django/db/models/fields/related.py", line 491, in __init__ super(ForeignObject, self).__init__(rel=rel, **kwargs) File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 172, in __init__ self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__ self._setup(name) File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 39, 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. [Finished in 1.809s] Git GitHub (preview)
###該当のソースコード
#models.py #!/usr/bin/python from django.db import models from django.utils import timezone class Post(models.Model): author = models.ForeignKey('auth.User') title = models.CharField(max_length=200) text = models.TextField() created_date = models.DateTimeField( default=timezone.now) published_date = models.DateTimeField( blank=True, null=True) def publish(self): self.published_date = timezone.now() self.save() def __str__(self): return self.title
###該当のソースコード
#settings.py """ Django settings for mysite project. Generated by 'django-admin startproject' using Django 1.11. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'a50vp3o@9#*tldh*3bzb6voehi_)xv#bu&p1+i2ed1cf6!hu4(' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'mysite.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'mysite.wsgi.application' # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ LANGUAGE_CODE = 'ja-JP' TIME_ZONE = 'Asia/Tokyo' USE_I18N = True USE_L10N = True USE_TZ = False # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_URL = '/static/'
###試したこと
1.
djangoチュートリアルに従い、
export DJANGO_SETTINGS_MODULE=mysite.settings
django-admin runserver を実行したところ、ModuleNotFoundError: No module named 'mysite'というエラーが出ました。
python2,3ともにインストールしているので以下のサイトに従いmodels.pyのシェバン行を#!/usr/bin/python3に変更しましたが、以下のようにエラーが出ました。
■https://blogware.info/python/prog/shebang/
Unable to run /usr/bin/python3 Did you start Atom from the command line? atom . Is it in your PATH? PATH: /Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.6/bin
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
python3.6.2
mac OS
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。