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
# Assuming you have a Article Model like this | |
# class Article(models.Model): | |
# ... Some field | |
# media = models.FileField(upload_to="path_to_inner_media_folder", blank=True) | |
from django.core.files.base import ContentFile | |
import os | |
# Create an article with the associated model | |
new_article = Article() |
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
{ | |
"name": "flare", | |
"children": [ | |
{ | |
"name": "analytics", | |
"children": [ | |
{ | |
"name": "cluster", | |
"children": [ | |
{"name": "AgglomerativeCluster", "size": 3938}, |
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
""" Tool function to convert Generalized Time string | |
to Python datetime object | |
""" | |
import datetime | |
import pytz | |
def gt_to_dt(gt): | |
""" Convert GeneralizedTime string to python datetime object |
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
""" A decorator to easily use cProfile on function """ | |
import cProfile | |
def profiler(sort=-1, use_globals=False, use_locals=True): | |
def decr(func): | |
def wrp(*args, **kwargs): | |
g = globals() if use_globals else None | |
l = locals() if use_locals else None | |
cProfile.runctx("func(*args, **kwargs)", g, l, sort=sort) | |
return func(*args, **kwargs) |
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
DIRECTUS_KEY=<...> | |
DIRECTUS_SECRET=<...> | |
DIRECTUS_DB_DATABASE=<...> | |
DIRECTUS_DB_USER=<...> | |
DIRECTUS_DB_PASSWORD=<...> | |
DIRECTUS_CACHE_ENABLED=true | |
DIRECTUS_CACHE_STORE=redis | |
DIRECTUS_ADMIN_EMAIL=<...> | |
DIRECTUS_ADMIN_PASSWORD=<...> | |
DIRECTUS_PUBLIC_URL=https://<server_name>/directus/ # server_name is the one used in nginx. Note the slash at the end. |