diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.rst b/README.rst
index 8a8996a4..50617694 100644
--- a/README.rst
+++ b/README.rst
@@ -122,6 +122,7 @@ It prompts you for questions. Answer them::
use_sentry [n]: y
use_newrelic [n]: y
use_opbeat [n]: y
+ use_pycharm [n]: y
windows [n]: n
use_python2 [n]: y
Select open_source_license:
diff --git a/cookiecutter.json b/cookiecutter.json
index 28d31fe3..9e75f14b 100644
--- a/cookiecutter.json
+++ b/cookiecutter.json
@@ -15,6 +15,7 @@
"use_sentry": "n",
"use_newrelic": "n",
"use_opbeat": "n",
+ "use_pycharm": "n",
"windows": "n",
"use_python2": "n",
"open_source_license": ["MIT", "BSD", "Not open source"]
diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py
index 107d6f98..80742e86 100644
--- a/hooks/post_gen_project.py
+++ b/hooks/post_gen_project.py
@@ -3,7 +3,8 @@ Does the following:
1. Generates and saves random secret key
2. Removes the taskapp if celery isn't going to be used
-3. Copy files from /docs/ to {{ cookiecutter.repo_name }}/docs/
+3. Removes the .idea directory if PyCharm isn't going to be used
+4. Copy files from /docs/ to {{ cookiecutter.repo_name }}/docs/
TODO: this might have to be moved to a pre_gen_hook
@@ -100,6 +101,18 @@ def remove_task_app(project_directory):
)
shutil.rmtree(task_app_location)
+
+def remove_pycharm_dir(project_directory):
+ """
+ Removes directories related to PyCharm
+ if it isn't going to be used
+ """
+ idea_dir_location = os.path.join(PROJECT_DIRECTORY, '.idea/')
+ shutil.rmtree(idea_dir_location)
+
+ docs_dir_location = os.path.join(PROJECT_DIRECTORY, 'docs/pycharm/')
+ shutil.rmtree(docs_dir_location)
+
# IN PROGRESS
# def copy_doc_files(project_directory):
# cookiecutters_dir = DEFAULT_CONFIG['cookiecutters_dir']
@@ -125,5 +138,9 @@ make_secret_key(PROJECT_DIRECTORY)
if '{{ cookiecutter.use_celery }}'.lower() == 'n':
remove_task_app(PROJECT_DIRECTORY)
-# 3. Copy files from /docs/ to {{ cookiecutter.repo_name }}/docs/
+# 3. Removes the .idea directory if PyCharm isn't going to be used
+if '{{ cookiecutter.use_pycharm }}'.lower() != 'y':
+ remove_pycharm_dir(PROJECT_DIRECTORY)
+
+# 4. Copy files from /docs/ to {{ cookiecutter.repo_name }}/docs/
# copy_doc_files(PROJECT_DIRECTORY)
diff --git a/{{cookiecutter.repo_name}}/.gitignore b/{{cookiecutter.repo_name}}/.gitignore
index 4b288b5b..b4f3f5b9 100644
--- a/{{cookiecutter.repo_name}}/.gitignore
+++ b/{{cookiecutter.repo_name}}/.gitignore
@@ -38,7 +38,17 @@ htmlcov
*.pot
# Pycharm
-.idea
+.idea/*
+{% if cookiecutter.use_pycharm == 'y' %}
+# Provided default Pycharm Run/Debug Configurations should be tracked by git
+# In case of local modifications made by Pycharm, use update-index command
+# for each changed file, like this:
+# git update-index --assume-unchanged .idea/{{cookiecutter.repo_name}}.iml
+!.idea/runConfigurations/
+!.idea/{{cookiecutter.repo_name}}.iml
+!.idea/vcs.xml
+!.idea/webResources.xml
+{% endif %}
# Vim
diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__migrate.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__migrate.xml
new file mode 100644
index 00000000..6a7b1b06
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__migrate.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver.xml
new file mode 100644
index 00000000..7143f167
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver_plus.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver_plus.xml
new file mode 100644
index 00000000..6a12a140
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver_plus.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___all.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___all.xml
new file mode 100644
index 00000000..9da92103
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___all.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___class__TestUser.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___class__TestUser.xml
new file mode 100644
index 00000000..eda23609
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___class__TestUser.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___file__test_models.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___file__test_models.xml
new file mode 100644
index 00000000..e35ff02a
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___file__test_models.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___module__users.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___module__users.xml
new file mode 100644
index 00000000..70ef8e96
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___module__users.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___specific__test_get_absolute_url.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___specific__test_get_absolute_url.xml
new file mode 100644
index 00000000..d5a7c643
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___specific__test_get_absolute_url.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/{{cookiecutter.repo_name}}/.idea/vcs.xml b/{{cookiecutter.repo_name}}/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/{{cookiecutter.repo_name}}/.idea/webResources.xml b/{{cookiecutter.repo_name}}/.idea/webResources.xml
new file mode 100644
index 00000000..e0fc860f
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/webResources.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/{{cookiecutter.repo_name}}/.idea/{{cookiecutter.repo_name}}.iml b/{{cookiecutter.repo_name}}/.idea/{{cookiecutter.repo_name}}.iml
new file mode 100644
index 00000000..f78e31fc
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/.idea/{{cookiecutter.repo_name}}.iml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/{{cookiecutter.repo_name}}/Dockerfile b/{{cookiecutter.repo_name}}/compose/django/Dockerfile
similarity index 100%
rename from {{cookiecutter.repo_name}}/Dockerfile
rename to {{cookiecutter.repo_name}}/compose/django/Dockerfile
diff --git a/{{cookiecutter.repo_name}}/Dockerfile-dev b/{{cookiecutter.repo_name}}/compose/django/Dockerfile-dev
similarity index 100%
rename from {{cookiecutter.repo_name}}/Dockerfile-dev
rename to {{cookiecutter.repo_name}}/compose/django/Dockerfile-dev
diff --git a/{{cookiecutter.repo_name}}/dev.yml b/{{cookiecutter.repo_name}}/dev.yml
index b48f53c8..359f6e91 100644
--- a/{{cookiecutter.repo_name}}/dev.yml
+++ b/{{cookiecutter.repo_name}}/dev.yml
@@ -13,7 +13,7 @@ services:
django:
build:
context: .
- dockerfile: Dockerfile-dev
+ dockerfile: ./compose/django/Dockerfile-dev
command: python /app/manage.py runserver_plus 0.0.0.0:8000
depends_on:
- postgres
@@ -25,3 +25,17 @@ services:
- "8000:8000"
links:
- postgres
+{% if cookiecutter.use_pycharm == 'y' %}
+ pycharm:
+ build:
+ context: .
+ dockerfile: ./compose/django/Dockerfile-dev
+ depends_on:
+ - postgres
+ environment:
+ - POSTGRES_USER={{cookiecutter.repo_name}}
+ volumes:
+ - .:/app
+ links:
+ - postgres
+{% endif %}
diff --git a/{{cookiecutter.repo_name}}/docker-compose.yml b/{{cookiecutter.repo_name}}/docker-compose.yml
index 798cb232..c1ae2cbf 100644
--- a/{{cookiecutter.repo_name}}/docker-compose.yml
+++ b/{{cookiecutter.repo_name}}/docker-compose.yml
@@ -10,6 +10,7 @@ services:
django:
build:
context: .
+ dockerfile: ./compose/django/Dockerfile
user: django
depends_on:
- postgres
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/configuration.rst b/{{cookiecutter.repo_name}}/docs/pycharm/configuration.rst
new file mode 100644
index 00000000..5d1a8759
--- /dev/null
+++ b/{{cookiecutter.repo_name}}/docs/pycharm/configuration.rst
@@ -0,0 +1,72 @@
+Docker Remote Debugging
+=======================
+
+To connect to python remote interpreter inside docker, you have to make sure first, that Pycharm is aware of your docker.
+
+Go to *Settings > Build, Execution, Deployment > Docker*. If you are on linux, you can use docker directly using its socket `unix:///var/run/docker.sock`, if you are on Windows or Mac, make sure that you have docker-machine installed, then you can simply *Import credentials from Docker Machine*.
+
+.. image:: images/1.png
+
+Configure Remote Python Interpreter
+-----------------------------------
+
+This repository comes with already prepared "Run/Debug Configurations" for docker.
+
+.. image:: images/2.png
+
+But as you can see, at the beggining there is something wrong with them. They have red X on django icon, and they cannot be used, withot configuring remote python interpteter. To do that, you have to go to *Settings > Build, Execution, Deployment* first.
+
+
+Next, you have to add new remote python interpreter, based on already tested deployment settings. Go to *Settings > Project > Project Interpreter*. Click on the cog icon, and click *Add Remote*.
+
+.. image:: images/3.png
+
+Switch to *Docker Compose* and select `dev.yml` file from directory of your project, next set *Service name* to `django`
+
+.. image:: images/4.png
+
+Because Pycharm restarts container every time you use Configuration Run, to not have server restarted during running tests, we defined second service in `dev.yml` file called pycharm. To use it, you have to add interpreter of second service as well.
+
+.. image:: images/5.png
+
+The final result should be:
+
+.. image:: images/6.png
+
+Having that, click *OK*. Close *Settings* panel, and wait few seconds...
+
+.. image:: images/7.png
+
+After few seconds, all *Run/Debug Configurations* should be ready to use.
+
+.. image:: images/8.png
+
+**Things you can do with provided configuration**:
+
+* run and debug python code
+.. image:: images/f1.png
+* run and debug tests
+.. image:: images/f2.png
+.. image:: images/f3.png
+* run and debug migrations or different django managment commands
+.. image:: images/f4.png
+* and many others..
+
+Known issues
+------------
+
+* Pycharm hangs on "Connecting to Debugger"
+
+.. image:: images/issue1.png
+
+This might be fault of your firewall. Take a look on this ticket - https://youtrack.jetbrains.com/issue/PY-18913
+
+* Modified files in `.idea` directory
+
+Most of the files from `.idea/` were added to `.gitignore` with a few exceptions, which were made, to provide "ready to go" configuration. After adding remote interpreter some of these files are altered by PyCharm:
+
+.. image:: images/issue2.png
+
+In theory you can remove them from repository, but then, other people will lose a ability to initialize a project from provided configurations as you did. To get rid of this annoying state, you can run command::
+
+ $ git update-index --assume-unchanged {{cookiecutter.repo_name}}.iml
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/1.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/1.png
new file mode 100644
index 00000000..06908a12
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/1.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/2.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/2.png
new file mode 100644
index 00000000..1fb8cf1e
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/2.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/3.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/3.png
new file mode 100644
index 00000000..32c93351
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/3.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/4.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/4.png
new file mode 100644
index 00000000..cf07f9d8
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/4.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/5.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/5.png
new file mode 100644
index 00000000..39fac959
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/5.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/6.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/6.png
new file mode 100644
index 00000000..0cd70d24
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/6.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/7.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/7.png
new file mode 100644
index 00000000..4f8807e3
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/7.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/8.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/8.png
new file mode 100644
index 00000000..05946f2c
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/8.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/f1.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/f1.png
new file mode 100644
index 00000000..2d8c4b6c
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/f1.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/f2.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/f2.png
new file mode 100644
index 00000000..b123a478
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/f2.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/f3.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/f3.png
new file mode 100644
index 00000000..713ab543
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/f3.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/f4.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/f4.png
new file mode 100644
index 00000000..11668ecd
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/f4.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/issue1.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/issue1.png
new file mode 100644
index 00000000..1bb68eee
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/issue1.png differ
diff --git a/{{cookiecutter.repo_name}}/docs/pycharm/images/issue2.png b/{{cookiecutter.repo_name}}/docs/pycharm/images/issue2.png
new file mode 100644
index 00000000..174f6fdf
Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm/images/issue2.png differ