İşte benim çözümüm. Aşağıdaki kodu, ayar dosyanızın altına ekleyin.
# Process --set command line option
import sys
# This module can be imported several times,
# check if the option has been retrieved already.
if not hasattr(sys, 'arg_set'):
# Search for the option.
args = filter(lambda arg: arg[:6] == '--set=', sys.argv[1:])
if len(args) > 0:
expr = args[0][6:]
# Remove the option from argument list, because the actual command
# knows nothing about it.
sys.argv.remove(args[0])
else:
# --set is not provided.
expr = ''
# Save option value for future use.
sys.arg_set = expr
# Execute the option value.
exec sys.arg_set
Sonra sadece herhangi bir yönetim komutuna herhangi bir kod geçmesi:
./manage.py runserver --set="DEBUG=True ; TEMPLATE_DEBUG=True"
Eğer 'piton manage.py runserver' denilen DEBUG her zaman ayarlamak istediğiniz ya da özel komutu var mı' piton manage.py foo' ve DEBUG’u içine koymak istiyor musun? – Kirill
Herhangi bir komut için herhangi bir ayar ayarlamak istiyorum. Bunun gibi: './manage.py --set =" DEBUG = True "runserver'. Belki de en kolay yol, settings.py'de bir komut satırı parametre değerini doğru olarak çalıştırmaktır. Ama kaynak kodunu hiç değiştirmemenin bir yolu olduğunu umuyordum. – raacer