Add cache table support (WIP)

This commit is contained in:
Christopher C. Wells 2020-01-28 20:45:37 -08:00 committed by Christopher Charbonneau Wells
parent c80ec252bc
commit c720f0b581
3 changed files with 26 additions and 11 deletions

View File

@ -5,9 +5,11 @@ from django.apps import apps
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.core.management.commands.flush import Command as Flush from django.core.management.commands.flush import Command as Flush
from django.core.management.commands.migrate import Command as Migrate from django.core.management.commands.createcachetable \
import Command as CreateCacheTable
from .fake import Command as Fake from .fake import Command as Fake
from .migrate import Command as Migrate
class Command(BaseCommand): class Command(BaseCommand):
@ -25,7 +27,6 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
verbosity = options['verbosity'] verbosity = options['verbosity']
database = options['database']
flush = Flush() flush = Flush()
flush.handle(**options) flush.handle(**options)
@ -44,21 +45,18 @@ class Command(BaseCommand):
# Ignore apps without migrations. # Ignore apps without migrations.
pass pass
# Run migrations.
migrate = Migrate() migrate = Migrate()
options['app_label'] = None options['app_label'] = None
options['migration_name'] = None options['migration_name'] = None
migrate.handle(*args, **options) migrate.handle(*args, **options)
self.UserModel._default_manager.db_manager(database).create_superuser( # Create configured cache tables.
**{ create_cache_table = CreateCacheTable()
self.UserModel.USERNAME_FIELD: 'admin', options['dry_run'] = None
'email': 'admin@admin.admin', create_cache_table.handle(*args, **options)
'password': 'admin'
}
)
if verbosity > 0:
self.stdout.write('Superuser created successfully.')
# Populate database with fake data.
fake = Fake() fake = Fake()
fake.handle(*args, **options) fake.handle(*args, **options)

View File

@ -91,6 +91,17 @@ TEMPLATES = [
] ]
# Cache
# https://docs.djangoproject.com/en/3.0/topics/cache/
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'cache_default',
}
}
# WGSI # WGSI
# https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ # https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/

View File

@ -208,6 +208,12 @@ gulp.task('compilemessages', function(cb) {
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb); spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
}); });
gulp.task('createcachetable', function(cb) {
var command = ['run', 'python', 'manage.py', 'createcachetable'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('fake', function(cb) { gulp.task('fake', function(cb) {
var command = ['run', 'python', 'manage.py', 'fake']; var command = ['run', 'python', 'manage.py', 'fake'];
command = command.concat(process.argv.splice(3)); command = command.concat(process.argv.splice(3));