Skip to content

Instantly share code, notes, and snippets.

@t1f7
t1f7 / *.py
Created October 11, 2017 11:21
Django urls trailing slash not working as expected
# https://stackoverflow.com/questions/1596552/django-urls-without-a-trailing-slash-do-not-redirect
# https://stackoverflow.com/questions/35964409/django-url-without-trailing-slash-not-working
# https://www.reddit.com/r/django/comments/5nlsv6/urls_without_a_trailing_slash_working_incorrectly/
'''
This problem is /<slug> dependent.
You should update your urls to fix it, check example below.
'''
@t1f7
t1f7 / servicehost.py
Created March 22, 2019 07:26
Django service application with persistent connection
# init django
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), 'apps'))
is_production = os.path.isfile('.production')
if is_production:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "conf.settings.production")