LoginSignup
1
0

More than 3 years have passed since last update.

Django + Dockerでのエラー

Last updated at Posted at 2020-09-16

はじめに

この記事ではDjango + Dockerのアプリ開発でおきたエラーとその対処法を書いていきます。

ERROR: No container found for web_1

いろいろ試してみてたのですが、一向に対処法がわからなかったのですが、次のようにターミナルに打ち込めば解決しました。

terminal
$ docker-compose up -d

参考記事
ERROR: No container found for web_1 #11045

TypeError: Field 'id' expected a number but got datetime.datetime(2020, 9, 16, 2, 52, 51, 44897, tzinfo=).

models.pyのForignkeyがあるところに次のように追記しました。

models.py
user = models.OneToOneField(
        User,
        verbose_name='ユーザー',
        on_delete=models.CASCADE,
        default=1   #追記
    )

これで解決しました。

django.db.utils.OperationalError: could not translate host name "db" to address: Name or service not known

sqlite3を使っていたのですが、このエラーが頻繁に出るので、Postgresqlを導入しました。

手順としてはこちらを参照してください。

ERROR: yaml.scanner.ScannerError: while scanning for the next token

このエラーでは「docker-compose.yml」のインデントを確認してみてください。
コメントアウトしているものでも、インデントがずれていると怒られるので注意してください。

yaml.parser.ParserError: while parsing a block mapping

このエラーでも「docker-compose.yml」のインデントを確認してみてください。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0