项目作者: renatoaloi

项目描述 :
Boilerplate for Django running on Docker
高级语言: Dockerfile
项目地址: git://github.com/renatoaloi/django-docker-boilerplate.git
创建时间: 2019-01-14T19:34:59Z
项目社区:https://github.com/renatoaloi/django-docker-boilerplate

开源协议:

下载


Django-docker boilerplate

Install Windows

Run following line to create composeexample project

  1. docker-compose run web django-admin.py startproject composeexample .

Change database connection from sqlite to postgres updating the following in composeexample/settings.py file

  1. DATABASES = {
  2. 'default': {
  3. 'ENGINE': 'django.db.backends.postgresql',
  4. 'NAME': 'postgres',
  5. 'USER': 'postgres',
  6. 'HOST': 'db',
  7. 'PORT': 5432,
  8. }
  9. }

Run the docker-compose up command from the top level directory for your project.

Usage

Navigate to http://localhost:8000 if you’re using Docker for Windows.

If you’re using Docker Toolbox, type the command below to find out the virtual host IP address:

  1. docker-machine ip default

And navigate to the IP address discovered above, for instance: http://192.168.99.101:8000

Access PostgreSQL Database

To access the database run the following command:

  1. docker run -it --rm --link esdjango_db_1:db --net esdjango_default postgres psql -h db -U postgres

Notes

In certain platforms (Windows 10) you might need to edit ALLOWED_HOSTS inside settings.py. In development enviroment you can set the value to:

  1. ALLOWED_HOSTS = ['*']

More Info

https://docs.docker.com/compose/django/