Skip to content

Serving PWA-related files #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion home/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'build/static')]
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'build/static'), os.path.join(BASE_DIR, 'non_generated_static')]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
SITE_ID = 1
Expand Down
19 changes: 19 additions & 0 deletions home/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
from django.contrib import admin
from django.urls import path, include, re_path
from django.views.generic import TemplateView
from django.conf import settings
import os


# The precache-manifest may be generated with a new name, so we need to get it manually
files_in_root = []
for file in os.listdir(os.path.join(settings.BASE_DIR, 'build')):
files_in_root.append(file)
precache_manifest_path = [f for f in files_in_root if ("precache-manifest" in f)][0]

urlpatterns = [
path('asset-manifest.json', (TemplateView.as_view(template_name="asset-manifest.json",
content_type='application/manifest+json', )),
name='asset-manifest.json'),
path('service-worker.js', (TemplateView.as_view(template_name="service-worker.js",
content_type='application/javascript', )),
name='service-worker.js'),
path(precache_manifest_path, (
TemplateView.as_view(template_name=precache_manifest_path,
content_type='application/javascript', )),
name=precache_manifest_path),
path('api-auth/', include('rest_framework.urls')),
path('rest-auth/', include('rest_auth.urls')),
path('rest-auth/registration/', include('rest_auth.registration.urls')),
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="manifest" href="{% static 'manifest.json' %}">
<link rel="shortcut icon" href="{% static 'favicon.ico' %}">
<title>Django React Boilerplate</title>
</head>
<body>
Expand Down