This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from customerio import CustomerIO | |
site_id = '' | |
api_key = '' | |
cio = CustomerIO(site_id, api_key) | |
with open('data.csv', 'r') as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@register.filter(name='format_phonenumber') | |
def format_phonenumber(phone, country='TR'): | |
""" | |
Usage: | |
{{ user.phone|format_phonenumber }} | |
{{ user.phone|format_phonenumber: 'TR' }} | |
""" | |
import phonenumbers | |
return phonenumbers.format_number( | |
phonenumbers.parse(phone, country), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
register = template.Library() | |
@register.filter(name='md5') | |
def md5(value): | |
""" | |
Usage: | |
{{ user.email|md5 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
register = template.Library() | |
@register.filter(name='amp') | |
def amp(value): | |
""" | |
Usage: | |
{{ article.body|amp }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
def home(request): | |
context = { | |
'name': 'Umut', | |
'language': 'Türkçe', | |
} | |
return render(request, 'home.html', context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEMPLATES = [ | |
{ | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': [], | |
'APP_DIRS': True, | |
'OPTIONS': { | |
'context_processors': [ | |
'django.template.context_processors.request', | |
], | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
def constants(request): | |
return { | |
'BASE_TITLE': settings.BASE_TITLE, | |
'BASE_URL': settings.BASE_URL, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEMPLATES = [ | |
{ | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': ['templates'], | |
'APP_DIRS': True, | |
'OPTIONS': { | |
'context_processors': [ | |
# ... | |
'blog.context_processors.constants', | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from blog.models import Tag | |
def tags(request): | |
published_tags = Tag.objects\ | |
.filter(is_published=True, posts__is_published=True)\ | |
.exclude(posts=None)\ | |
.order_by('name')\ | |
.distinct() | |
return {'tags': published_tags} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEMPLATES = [ | |
{ | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': ['templates'], | |
'APP_DIRS': True, | |
'OPTIONS': { | |
'context_processors': [ | |
# ... | |
'blog.context_processors.constants', | |
'blog.context_processors.tags', |
OlderNewer