Django에서 postgresql 및 실행 코드 설정

4001 단어 데이터베이스

postgresql 데이터베이스 만들기

ubuntuq@ubuntuq-HP-Compaq-6910p-RH241AV:~$ su postgres
  : 
postgres@ubuntuq-HP-Compaq-6910p-RH241AV:/home/ubuntuq$ psql
psql (9.3.11)
Type "help" for help.
postgres=# CREATE DATABASE pol_gov_mon owner deploy;
CREATE DATABASE
postgres=#

django에postgresql 데이터베이스 정보 설정하기


PostgreSQL의 데이터베이스 정보를django 설정에 settings.py 부분 코드는 다음과 같습니다.
DATABASES = {
    'default': {
         'ENGINE': 'django.db.backends.postgresql_psycopg2',
         'NAME': 'pol_gov_mon',
         'USER': 'deploy',
         'PASSWORD': 'XXX',
         'HOST': '127.0.0.1',
         'PORT': '5432',
         #'CONN_MAX_AGE': 5,
     }
}

django에서 데이터베이스 이동 및 실행 코드

ubuntuq@ubuntuq-HP-Compaq-6910p-RH241AV:~/  /wuran$ python manage.py syncdb
#     
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table jiandu_gov_pol_air_result
Creating table jiandu_gov_pol_water_result
Creating table jiandu_gov_pol_mental_result
Creating table jiandu_gov_pol_danger_result

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): yes
Username (leave blank to use 'ubuntuq'): #   
Email address: #   
Password: 
Password (again): 
Error: Blank passwords aren't allowed.
Password: #    
Password (again):#     
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
ubuntuq@ubuntuq-HP-Compaq-6910p-RH241AV:~/  /wuran$ python manage.py xinjiang getall
#      

좋은 웹페이지 즐겨찾기