[PYTHON] Django + Docker

Introduction

In this article, I will write about the errors that occurred in Django + Docker application development and how to deal with them.

ERROR: No container found for web_1 I tried various things, but I couldn't figure out how to deal with it, but I solved it by typing in the terminal as follows.

terminal


$ docker-compose up -d

Reference article 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=).

I added the following to the location of the Foreign key in models.py.

models.py


user = models.OneToOneField(
        User,
        verbose_name='user',
        on_delete=models.CASCADE,
        default=1   #Postscript
    )

This solved it.

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

I was using sqlite3, but I get this error frequently, so I introduced Postgresql.

See here for the procedure.

ERROR: yaml.scanner.ScannerError: while scanning for the next token For this error, check the indentation of "docker-compose.yml". Please note that even if you comment out, you will get angry if the indentation is off.

yaml.parser.ParserError: while parsing a block mapping Please check the indent of "docker-compose.yml" even with this error.

Recommended Posts

Django + Docker
Django + Docker command
Django
Docker + Django + React environment construction
django update
Django note 4
Django memorandum
django search
Django installation
Django Summary
Docker installation
Deploy a Django application with Docker
Django # 2 (template)
Django Note 5
Django hands-on
Touch django
django notes
Django basics
Django Shoho
Django defaults
Django Glossary
Django search
Install Django
Django: References
Django Note 1
Django note 3
Django note 2
Django startup
Django notes
Django NullCharField
Django ~ settings.py edition ~
About Docker Volume
pykintone on Docker
Django Heroku Deploy 1
Django HTML Template # 2
Build Django + NGINX + PostgreSQL development environment with Docker
Make Django's environment Docker (Docker + Django + Gunicorn + nginx) Part 2
Reintroduction to Docker
Django Contact Form 2
Django model: ManyToManyField
What is Django? .. ..
Django function-based view
Python Django Tutorial (5)
Django Learning Memo
Python Django Tutorial (2)
[Django] as_view () notes
First Django Challenge
django makemigarations createsuperuser
Django related sites
Internationalization with django
Django version check
django table creation
How to reflect ImageField in Django + Docker (pillow)
Django begins part 4
Django 1.9 for internationalization
CentOS8 --Play --Django
CentOS8 --Install --Django
[Python] Build a Django development environment with Docker
django tutorial memo
django environment construction
Django Template notes