File tree Expand file tree Collapse file tree 5 files changed +37
-0
lines changed
Expand file tree Collapse file tree 5 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ from __future__ import unicode_literals
3+ from __future__ import print_function
4+ from django .conf import settings
5+ from getpass import getpass
6+
7+
8+ class PromptForPragmaKeyMixin (object ):
9+ """""
10+ This is a universal command that you can have other management commands
11+ inherit from in case they need database access.
12+ """
13+
14+ def handle (self , * args , ** options ):
15+ if not hasattr (settings , 'PRAGMA_KEY' ) or not settings .PRAGMA_KEY :
16+ print ("There is no SQL Cipher key defined, it's unsafe to store in your settings. Please input your key" )
17+ key = getpass ("Key: " )
18+ settings .PRAGMA_KEY = key
19+ super (PromptForPragmaKeyMixin , self ).handle (* args , ** options )
Original file line number Diff line number Diff line change 1+
2+ from django .core .management .commands .migrate import Command as BaseCommand
3+
4+ from ._mixins import PromptForPragmaKeyMixin
5+
6+
7+ class Command (PromptForPragmaKeyMixin , BaseCommand ):
8+ """
9+ Before migrating, we need to know the pragma key to access the database. If
10+ it does not exist, retrieve it from command line input.
11+ """
12+ pass
Original file line number Diff line number Diff line change 1+ from django .core .management .commands .runserver import Command as RunserverCommand
2+
3+ from ._mixins import PromptForPragmaKeyMixin
4+
5+ class Command (PromptForPragmaKeyMixin , RunserverCommand ):
6+ pass
You can’t perform that action at this time.
0 commit comments