import yaml try: from yaml import CLoader as Loader, CDumper as Dumper except ImportError: from yaml import Loader, Dumper import markdown from study.utils import generate_random_string # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) CONFIG_DEFAULTS = { 'site_url': 'http://127.0.0.1:9500', 'debug_mode': False, 'secret_key': generate_random_string(48), 'postgresql': { 'host': '127.0.0.1', 'port': 5432, 'database': 'study', 'username': '******', 'password': '******', 'conn_max_age': 120, }, 'redis': { 'host': '127.0.0.1', 'port': 6379, 'database': 1, 'password': '******', }, 'smtp': {
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os from collections import defaultdict import yaml try: from yaml import CLoader as Loader, CDumper as Dumper except ImportError: from yaml import Loader, Dumper from study.utils import generate_random_string BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) CONFIG_DEFAULTS = { 'site_url': 'http://127.0.0.1:9500', 'debug_mode': False, 'secret_key': generate_random_string(48), 'postgresql': { 'host': '127.0.0.1', 'port': 5432, 'database': 'study', 'username': '******', 'password': '******', 'conn_max_age': 120, }, 'redis': { 'host': '127.0.0.1', 'port': 6379, 'database': 1, 'password': '******', }, 'smtp': {
def save(self, *args, **kwargs): if self.pk is None: self.code = generate_random_string(32, chars=string.ascii_letters + string.digits) return super(UserCode, self).save(*args, **kwargs)