2016-08-16 26 views
0

Django Commandクラスのcreatesuperuser.pyhandleメソッドをオーバーライドする必要があります。Django manage.pyのコマンドを正しく上書きするには?

私はmyappという\管理\を作成した\ createsuperuser.pyコマンド:

import getpass 
import sys 

import django.contrib.auth.management.commands.createsuperuser as makesuperuser 

from django.contrib.auth.management import get_default_username 
from django.contrib.auth.password_validation import validate_password 
from django.core import exceptions 
from django.core.management.base import CommandError 
from django.utils.encoding import force_str 
from django.utils.text import capfirst 

class Command(makesuperuser.Command): 
    def handle(self, *args, **options): 
     # the rest of code is copied from Django source and is almost 
     # standart except few changes related to how info of 
     # REQUIRED_FIELDS is shown 

私は、端末./manage.py createsuperuserに私はすべての変更を見ないでくださいとき。ファイルの名前を変更してmycmd.pyとし、./manage.py mycmdとすると、すべてが期待通りに機能し始めます。

変更の方法./manage.py createsuperuserを使用する必要がありますか?

答えて

1

アプリケーション名をINSTALLED_APPSのリストの一番上に置きます。

関連する問題