Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit 09dc41a

Browse files
committed
added django shell in jupyter notebook
1 parent c04782e commit 09dc41a

File tree

7 files changed

+35
-1
lines changed

7 files changed

+35
-1
lines changed

Diff for: README.md

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ Open `http://localhost` in your browser
88

99
You can specify environment variables for docker-compose by adding an `.env` file to the root of the project based on `.env.template`.
1010

11+
### Access Django Shell in Jupyter Notebook
12+
13+
```
14+
docker exec -it backend bash
15+
# cd notebooks/
16+
# ../manage.py shell_plus --notebook
17+
```
18+
19+
1120
## CloudFormation Commands
1221

1322
### sync templates to S3 bucket

Diff for: backend/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ENV PYTHONDONTWRITEBYTECODE 1
44
RUN mkdir /code
55
WORKDIR /code
66
ADD requirements.txt /code/
7+
ADD notebooks/jupyter_notebook_config.py /root/.jupyter/
78
RUN pip install -r requirements.txt
89
ADD . /code/
910
EXPOSE 8000

Diff for: backend/backend/settings.py

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
'django.contrib.staticfiles',
4141

4242
'corsheaders',
43+
'django_extensions',
4344

4445
'core',
4546

@@ -155,3 +156,10 @@
155156
AWS_STATIC_LOCATION = 'static'
156157
STATICFILES_STORAGE = 'backend.storage_backends.StaticStorage'
157158
STATIC_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{AWS_STATIC_LOCATION}/"
159+
160+
161+
NOTEBOOK_ARGUMENTS = [
162+
'--ip', '0.0.0.0',
163+
'--allow-root',
164+
'--no-browser',
165+
]

Diff for: backend/notebooks/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

Diff for: backend/requirements.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ django-cors-headers==2.5.0
55
celery==4.2.1
66
redis==3.2.0
77
jupyter==1.0.0
8-
pandas==0.24.2
8+
pandas==0.24.2
9+
django-extensions==2.1.6
10+
requests==2.21.0

Diff for: docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ services:
6060
- django-static:/code/static
6161
ports:
6262
- "8000:8000"
63+
- "8890:8888"
6364
networks:
6465
- main
6566
environment:

Diff for: nginx/dev/dev.conf

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ http {
1313
server backend:8000;
1414
}
1515

16+
upstream jupyter {
17+
server backend:8888;
18+
}
19+
1620
upstream frontend {
1721
server frontend:8080;
1822
}
@@ -54,6 +58,13 @@ http {
5458
proxy_set_header Connection "upgrade";
5559
}
5660

61+
# jupyter
62+
location /jupyter/ {
63+
proxy_http_version 1.1;
64+
proxy_set_header Connection "";
65+
proxy_pass http://jupyter/;
66+
}
67+
5768
# portainer
5869
location /redis-commander/ {
5970
proxy_http_version 1.1;

0 commit comments

Comments
 (0)