SushantGautam commited on
Commit
0ff05c8
·
1 Parent(s): 3b3925a

Update .gitignore, settings.py, urls.py, and Dockerfile for static and media file handling

Browse files
Files changed (4) hide show
  1. .gitignore +2 -1
  2. BridgeMentor/settings.py +4 -6
  3. BridgeMentor/urls.py +5 -9
  4. Dockerfile +2 -0
.gitignore CHANGED
@@ -1,4 +1,5 @@
1
  **/*.json
2
  venv
3
  migrations
4
- db.sqlite3*
 
 
1
  **/*.json
2
  venv
3
  migrations
4
+ db.sqlite3*
5
+ staticfiles
BridgeMentor/settings.py CHANGED
@@ -181,9 +181,7 @@ if os.environ.get('INSIDEDOCKER'):
181
  SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
182
 
183
  STATIC_URL = '/static/'
184
- STATICFILES_DIRS = [
185
- os.path.join(os.path.dirname(django.__file__),
186
- 'contrib', 'admin', 'static'),
187
- os.path.join(os.path.dirname(django.__file__), 'contrib',
188
- 'auth', 'static'), # Optional if using auth
189
- ]
 
181
  SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
182
 
183
  STATIC_URL = '/static/'
184
+ STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
185
+
186
+ media_url = '/media/'
187
+ media_root = os.path.join(BASE_DIR, 'media')
 
 
BridgeMentor/urls.py CHANGED
@@ -38,13 +38,9 @@ urlpatterns = [
38
  path('', include('core.urls')), # routes '' to your home app
39
  # routes '' to your home app
40
  path('logout', logout_view, name='logout'),
41
-
42
-
43
  ]
44
- if settings.DEBUG:
45
- urlpatterns += static(settings.STATIC_URL, document_root=os.path.join(
46
- os.path.dirname(django.__file__), 'contrib', 'admin', 'static'))
47
- # urlpatterns += static(settings.STATIC_URL,
48
- # document_root=settings.STATIC_ROOT)
49
- # urlpatterns += static(settings.MEDIA_URL,
50
- # document_root=settings.MEDIA_ROOT)
 
38
  path('', include('core.urls')), # routes '' to your home app
39
  # routes '' to your home app
40
  path('logout', logout_view, name='logout'),
 
 
41
  ]
42
+
43
+ urlpatterns += static(settings.STATIC_URL,
44
+ document_root=settings.STATIC_ROOT)
45
+ urlpatterns += static(settings.MEDIA_URL,
46
+ document_root=settings.MEDIA_ROOT)
 
 
Dockerfile CHANGED
@@ -22,6 +22,8 @@ COPY requirements.txt .
22
  RUN pip install --upgrade pip && pip install -r requirements.txt
23
  COPY . .
24
 
 
 
25
  # Install SSH client and other utilities
26
  RUN apt-get update && apt-get install -y \
27
  openssh-client \
 
22
  RUN pip install --upgrade pip && pip install -r requirements.txt
23
  COPY . .
24
 
25
+ RUN python manage.py collectstatic --noinput
26
+
27
  # Install SSH client and other utilities
28
  RUN apt-get update && apt-get install -y \
29
  openssh-client \