2012-06-05 3 views
9

Sqlite3 및 Python 2.7을 사용하여 장고 프로젝트에 데이터베이스를 추가하려고합니다.Python 2.7에서 Sqlite3을 사용하여 Django 프로젝트에 데이터베이스 추가

이처럼 내 setting.py 모양을 : 그것은 나 데이터베이스를 만들 수 있습니다

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 
     'NAME': 'dev.db',      # Or path to database file if using sqlite3. 
     'USER': '',      # Not used with sqlite3. 
     'PASSWORD': '',     # Not used with sqlite3. 
     'HOST': '',      # Set to empty string for localhost. Not used with sqlite3. 
     'PORT': '',      # Set to empty string for default. Not used with sqlite3. 
    } 
} 

그리고 슈퍼 유저 만들기 위해 나에게 묻는다 :

You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): 

을 내가 예, 그것을 입력 할 때 나에게이 오류 메시지를 준다.

오류 메시지 :

Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line 
    utility.execute() 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute 
    output = self.handle(*args, **options) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle 
    return self.handle_noargs(**options) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 110, in handle_noargs 
    emit_post_sync_signal(created_models, verbosity, interactive, db) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal 
    interactive=interactive, db=db) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 172, in send 
    response = receiver(signal=self, sender=sender, **named) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 73, in create_superuser 
    call_command("createsuperuser", interactive=True, database=db) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command 
    return klass.execute(*args, **defaults) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute 
    output = self.handle(*args, **options) 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle 
    default_username = get_default_username() 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username 
    default_username = get_system_username() 
    File "/Users/IMAC/work3/env/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username 
    return getpass.getuser().decode(locale.getdefaultlocale()[1]) 
    File "/Users/IMAC/work3/env/lib/python2.7/locale.py", line 496, in getdefaultlocale 
    return _parse_localename(localename) 
    File "/Users/IMAC/work3/env/lib/python2.7/locale.py", line 428, in _parse_localename 
    raise ValueError, 'unknown locale: %s' % localename 
ValueError: unknown locale: UTF-8 

어떻게 내가 위의 오류를 해결합니까? 수퍼 유저를 추가 할 수없는 이유는 무엇입니까? 나는 어떻게해야합니까? Python 2.7을 실행하고 있기 때문에이 문제가 발생할 수 있습니까?

+0

그것을 추가 그래서 ... 당신의 질문은 "어떻게 OS X에 로케일을 추가하는 방법은 무엇입니까?"입니다? –

+0

내가 파이썬 2.7을 실행하기 때문에 그것입니까? – lakesh

답변

16

유형이 상단에 이것을 넣어 당신은 파이썬 manage.py의 syncdb에게

export LC_CTYPE=en_US.UTF-8 
export LC_ALL=en_US.UTF-8 

을 실행하기 전에이 Btw은 내가는/usr/빈/파이썬에 있던 맥 OS X 파이썬을 사용하던 오류 ..가 해결됩니다.

그것이 자동으로 호출 할 수 있도록 있습니다 .. ./.bash_profile 파일에

+0

감사합니다. Mac에서이 기능을 사용할 수 있습니다. – Philip007

관련 문제