Skip to content
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

PWA_APP_ICONS_APPLE Setting Not Recognized Due to Absence in app_settings.py #107

Closed
max-taitola opened this issue Feb 12, 2024 · 1 comment · Fixed by #110
Closed

PWA_APP_ICONS_APPLE Setting Not Recognized Due to Absence in app_settings.py #107

max-taitola opened this issue Feb 12, 2024 · 1 comment · Fixed by #110

Comments

@max-taitola
Copy link

Description:

The project documentation suggests configuring PWA_APP_ICONS_APPLE for Apple-specific app icons in the settings.py. However, the progressive_web_app_meta inclusion tag in templatetags/pwa.py, which passes settings to the pwa.html template, only includes settings prefixed with PWA_ from app_settings.py. Since PWA_APP_ICONS_APPLE is not defined in app_settings.py, it cannot be utilized in the pwa.html template, leading to a discrepancy between the documentation and the actual functionality.

Steps to Reproduce:

Define PWA_APP_ICONS_APPLE in settings.py as per the documentation.
Implement the progressive_web_app_meta inclusion tag in a template.
Notice that PWA_APP_ICONS_APPLE does not take effect in the rendered HTML.
Expected Behavior:
PWA_APP_ICONS_APPLE should be recognized and used to generate Apple-specific app icon tags in the pwa.html template when defined in settings.py.

Actual Behavior:

Due to the absence of PWA_APP_ICONS_APPLE in app_settings.py, the setting is not passed to the pwa.html template, and thus, Apple-specific app icons are not rendered.

Suggested Fix:

Add a PWA_APP_ICONS_APPLE setting to app_settings.py, following the pattern used for other PWA_ settings. This would ensure that when PWA_APP_ICONS_APPLE is defined in settings.py, it is properly passed through to the pwa.html template.

PWA_APP_ICONS_APPLE = getattr(settings, "PWA_APP_ICONS_APPLE", [])

Error log:

Exception while resolving variable 'PWA_APP_ICONS_APPLE' in template 'pwa.html'. 2024-02-12T13:39:35.325982084Z Traceback (most recent call last): 2024-02-12T13:39:35.325992254Z File "/usr/local/lib/python3.12/site-packages/django/template/base.py", line 875, in _resolve_lookup 2024-02-12T13:39:35.326000396Z current = current[bit] 2024-02-12T13:39:35.326007008Z ~~~~~~~^^^^^ 2024-02-12T13:39:35.326013277Z File "/usr/local/lib/python3.12/site-packages/django/template/context.py", line 83, in __getitem__ 2024-02-12T13:39:35.326019544Z raise KeyError(key) 2024-02-12T13:39:35.326025655Z KeyError: 'PWA_APP_ICONS_APPLE' 2024-02-12T13:39:35.326031009Z 2024-02-12T13:39:35.326037268Z During handling of the above exception, another exception occurred: 2024-02-12T13:39:35.326043034Z 2024-02-12T13:39:35.326048662Z Traceback (most recent call last): 2024-02-12T13:39:35.326054329Z File "/usr/local/lib/python3.12/site-packages/django/template/base.py", line 881, in _resolve_lookup 2024-02-12T13:39:35.326061089Z if isinstance(current, BaseContext) and getattr( 2024-02-12T13:39:35.326070417Z ^^^^^^^^ 2024-02-12T13:39:35.326076297Z AttributeError: type object 'RequestContext' has no attribute 'PWA_APP_ICONS_APPLE' 2024-02-12T13:39:35.326081772Z 2024-02-12T13:39:35.326086971Z During handling of the above exception, another exception occurred: 2024-02-12T13:39:35.326092379Z 2024-02-12T13:39:35.326097633Z Traceback (most recent call last): 2024-02-12T13:39:35.326102966Z File "/usr/local/lib/python3.12/site-packages/django/template/base.py", line 891, in _resolve_lookup 2024-02-12T13:39:35.326108894Z current = current[int(bit)] 2024-02-12T13:39:35.326128944Z ^^^^^^^^ 2024-02-12T13:39:35.326134994Z ValueError: invalid literal for int() with base 10: 'PWA_APP_ICONS_APPLE' 2024-02-12T13:39:35.326140322Z 2024-02-12T13:39:35.326145646Z During handling of the above exception, another exception occurred: 2024-02-12T13:39:35.326150814Z 2024-02-12T13:39:35.326155966Z Traceback (most recent call last): 2024-02-12T13:39:35.326161107Z File "/usr/local/lib/python3.12/site-packages/django/template/base.py", line 898, in _resolve_lookup 2024-02-12T13:39:35.326166941Z raise VariableDoesNotExist( 2024-02-12T13:39:35.326176271Z django.template.base.VariableDoesNotExist: Failed lookup for key [PWA_APP_ICONS_APPLE] in [{'True': True, 'False': False, 'None': None}, {'PWA_APP_BACKGROUND_COLOR': '#c3dcfd', 'PWA_APP_DEBUG_MODE': True, 'PWA_APP_DESCRIPTION': 'Financial management fyn', 'PWA_APP_DIR': 'ltr', 'PWA_APP_DISPLAY': 'standalone', 'PWA_APP_FETCH_URL': '/', 'PWA_APP_ICONS': [{'src': '/static/fm/icons/icon-72x72.png', 'size': '72x72', 'type': 'image/png', 'purpose': 'any'}, {'src': '/static/fm/icons/icon-72x72-mask.png', 'size': '72x72', 'type': 'image/png', 'purpose': 'maskable'}, {'src': '/static/fm/icons/icon-96x96.png', 'size': '96x96', 'type': 'image/png', 'purpose': 'any'}, {'src': '/static/fm/icons/icon-96x96-mask.png', 'size': '96x96', 'type': 'image/png', 'purpose': 'maskable'}, {'src': '/static/fm/icons/icon-128x128.png', 'size': '128x128', 'type': 'image/png', 'purpose': 'any'}, {'src': '/static/fm/icons/icon-128x128-mask.png', 'size': '128x128', 'type': 'image/png', 'purpose': 'maskable'}, {'src': '/static/fm/icons/icon-144x144.png', 'size': '144x144', 'type': 'image/png', 'purpose': 'any'}, {'src': '/static/fm/icons/icon-144x144-mask.png', 'size': '144x144', 'type': 'image/png', 'purpose': 'maskable'}, {'src': '/static/fm/icons/icon-152x152.png', 'size': '152x152', 'type': 'image/png', 'purpose': 'any'}, {'src': '/static/fm/icons/icon-152x152-mask.png', 'size': '152x152', 'type': 'image/png', 'purpose': 'maskable'}, {'src': '/static/fm/icons/icon-192x192.png', 'size': '192x192', 'type': 'image/png', 'purpose': 'any'}, {'src': '/static/fm/icons/icon-192x192-mask.png', 'size': '192x192', 'type': 'image/png', 'purpose': 'maskable'}, {'src': '/static/fm/icons/icon-384x384.png', 'size': '384x384', 'type': 'image/png', 'purpose': 'any'}, {'src': '/static/fm/icons/icon-384x384-mask.png', 'size': '384x384', 'type': 'image/png', 'purpose': 'maskable'}, {'src': '/static/fm/icons/icon-512x512.png', 'size': '512x512', 'type': 'image/png', 'purpose': 'any'}, {'src': '/static/fm/icons/icon-512x512-mask.png', 'size': '512x512', 'type': 'image/png', 'purpose': 'maskable'}, {'src': '/static/fm/icons/fm.svg', 'size': '512x512', 'type': 'image/svg', 'purpose': 'any'}], 'PWA_APP_LANG': 'fi', 'PWA_APP_NAME': 'fyn', 'PWA_APP_ORIENTATION': 'portrait', 'PWA_APP_ROOT_URL': '/', 'PWA_APP_SCOPE': '/', 'PWA_APP_SPLASH_SCREEN': [{'src': '/static/fm/icons/splash-640x1136.png', 'media': '(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)'}, {'src': '/static/fm/icons/splash-750x1334.png', 'media': '(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)'}, {'src': '/static/fm/icons/splash-1242x2208.png', 'media': '(device-width: 621px) and (device-height: 1104px) and (-webkit-device-pixel-ratio: 3)'}, {'src': '/static/fm/icons/splash-1125x2436.png', 'media': '(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3)'}, {'src': '/static/fm/icons/splash-828x1792.png', 'media': '(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2)'}, {'src': '/static/fm/icons/splash-1242x2688.png', 'media': '(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3)'}, {'src': '/static/fm/icons/splash-1536x2048.png', 'media': '(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2)'}, {'src': '/static/fm/icons/splash-1668x2224.png', 'media': '(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2)'}, {'src': '/static/fm/icons/splash-1668x2388.png', 'media': '(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2)'}, {'src': '/static/fm/icons/splash-2048x2732.png', 'media': '(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2)'}], 'PWA_APP_START_URL': '/pwa/', 'PWA_APP_STATUS_BAR_COLOR': 'default', 'PWA_APP_THEME_COLOR': '#1878f7', 'PWA_SERVICE_WORKER_PATH': PosixPath('/fm/djangoapp/fm/templates/serviceworker.js'), 'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7fb77a667100>>}] 2024-02-12T13:39:35.354652290Z

@DmytroLitvinov
Copy link

Hi there,
Same issue. Hi @silviolleite , do you accept PR for fixing the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants