Skip to content

Instantly share code, notes, and snippets.

View teury's full-sized avatar

Teury Diaz teury

View GitHub Profile
@teury
teury / config.py
Created January 31, 2018 17:08 — forked from jerivas/config.py
One-click Django language select
# settings.py
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.i18n',
)
# urls.py (outside i18n_patterns)
(r'^i18n/', include('django.conf.urls.i18n')),
@teury
teury / language_query_string.py
Last active November 9, 2019 23:40
Django Middleware language change query string ?hl=langcode
import django
from django.utils import translation
from django.shortcuts import redirect, reverse
def is_django_greater_than_1_10():
main_version = django.VERSION[0]
if main_version > 1:
return True
@teury
teury / Nginx_uwsig_django.md
Created October 19, 2021 03:22 — forked from junstrix/Nginx_uwsig_django.md
Nginx, Uwsgi, Virtualenv and Django
@teury
teury / example_usage.py
Created August 22, 2024 23:55 — forked from marty0678/example_usage.py
Django Rest Framework Base Model CRUD Class
# Views
class UserProfileViewSet(BaseModelViewSet):
"""View set for the UserProfile."""
ENABLE_LIST = True
ENABLE_RETRIEVE = True
ENABLE_PARTIAL_UPDATE = True
ENABLE_PAGINATION = True
LIST_CACHE_KEY = "users:user-profiles-list"