Djnago中的配置postgresql

时间:2019-04-12 09:47:53

标签: django

我是Django的新手,如果我忘了添加一些东西,对不起。

我正在尝试将SQLite数据库更改为Postgres。我将CurrBal更改为包括postgres而不是sqlite,但是DELIMITER $$ DROP PROCEDURE IF EXISTS `curdemo11` $$ CREATE PROCEDURE `curdemo11`(OUT res VARCHAR(100)) BEGIN DECLARE finished ,done BOOLEAN DEFAULT FALSE; DECLARE a,i INT; DECLARE accountID,companyID,yearMasterID INT; DECLARE currClosing,curreOpening,previousBal DOUBLE(10,4); DECLARE cur1 CURSOR FOR SELECT AccountID FROM (SELECT ID,AccountID,CompanyID,YearMasterID,CurrBal,OpeningBalance FROM `Closing_balance_child` WHERE CurrBal != '0.0000' AND OpeningBalance != '0.0000' GROUP BY AccountID,CompanyID,YearMasterID) AS t GROUP BY AccountID HAVING COUNT(AccountID) > 1 LIMIT 2; DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = TRUE; OPEN cur1; cur1_loop : LOOP FETCH FROM cur1 INTO a ; IF finished THEN CLOSE cur1; LEAVE cur1_loop; END IF; BLOCK2: BEGIN DECLARE cur2 CURSOR FOR SELECT AccountID,CompanyID,YearMasterID,CurrBal,OpeningBalance FROM `Closing_balance_child` WHERE AccountID = a; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; OPEN cur2; cur2_loop1 : LOOP FETCH FROM cur2 INTO accountID,companyID,yearMasterID,currClosing,curreOpening; SET previousBal = currClosing; SET i=0; IF finished THEN SET finished = FALSE; CLOSE cur2; LEAVE cur2_loop1; END IF; SET res = a; IF (previousBal != curreOpening AND i != 0) THEN SET res = a; END IF; SET i=i+1; END LOOP cur2_loop1; END BLOCK2; END LOOP cur1_loop; END $$ DELIMITER ; CALL curdemo11(@res); SELECT @res; 仍在执行sqlite db(并向我展示settings.py。 这是我的数据库设置的样子:

python manage.py migrate

这是完整的错误:

OperationalError at / no such table: articles_article

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'grokoko_db', 'USER': 'grokoko', 'PASSWORD': 'GROKOKO_DB_PASS', 'HOST': 'localhost', 'PORT': '5432', } } 由于相同的问题而无法正常工作。使用setx命令将密钥和db传递作为环境变量添加。我真的不明白为什么,但是我有两个settings.py文件,但是当我尝试更深入地更改一个文件时,一切都变得疯狂了,而我得到OperationalError at / no such table: articles_article Request Method: GET Request URL: http://localhost:8000/ Django Version: 2.1.7 Exception Type: OperationalError Exception Value: no such table: articles_article Exception Location: C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 298 Python Executable: C:\Program Files (x86)\Python37-32\python.exe Python Version: 3.7.2 Python Path: ['F:\\Github\\Django\\Djangoject', 'C:\\Program Files (x86)\\Python37-32\\python37.zip', 'C:\\Program Files (x86)\\Python37-32\\DLLs', 'C:\\Program Files (x86)\\Python37-32\\lib', 'C:\\Program Files (x86)\\Python37-32', 'C:\\Users\\groko\\AppData\\Roaming\\Python\\Python37\\site-packages', 'C:\\Program Files (x86)\\Python37-32\\lib\\site-packages'] Server time: Fri, 12 Apr 2019 13:10:49 +0000 Error during template rendering In template F:\Github\Django\Djangoject\djangoject\templates\base_layout.html, error at line 0 no such table: articles_article 1 {% load static from staticfiles %} 2 3 <!DOCTYPE html> 4 <html> 5 <head> 6 <meta charset="utf-8"> 7 <title>Articles</title> 8 <link rel = "stylesheet" href = "{% static 'styles.css' %}"> 9 </head> 10 <body> Traceback Switch to copy-and-paste view C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\utils.py in _execute return self.cursor.execute(sql, params) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\sqlite3\base.py in execute return Database.Cursor.execute(self, query, params) ... ▶ Local vars The above exception (no such table: articles_article) was the direct cause of the following exception: C:\Program Files (x86)\Python37-32\lib\site-packages\django\core\handlers\exception.py in inner response = get_response(request) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\core\handlers\base.py in _get_response response = self.process_exception_by_middleware(e, request) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\core\handlers\base.py in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ... ▶ Local vars F:\Github\Django\Djangoject\articles\views.py in article_list return render(request, 'articles/article_list.html', {'articles': articles}) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\shortcuts.py in render content = loader.render_to_string(template_name, context, request, using=using) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\loader.py in render_to_string return template.render(context, request) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\backends\django.py in render return self.template.render(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\base.py in render return self._render(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\base.py in _render return self.nodelist.render(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\base.py in render bit = node.render_annotated(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\base.py in render_annotated return self.render(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\loader_tags.py in render return compiled_parent._render(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\base.py in _render return self.nodelist.render(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\base.py in render bit = node.render_annotated(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\base.py in render_annotated return self.render(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\loader_tags.py in render result = block.nodelist.render(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\base.py in render bit = node.render_annotated(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\base.py in render_annotated return self.render(context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\template\defaulttags.py in render len_values = len(values) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\query.py in __len__ self._fetch_all() ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\query.py in _fetch_all self._result_cache = list(self._iterable_class(self)) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\query.py in __iter__ results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\sql\compiler.py in execute_sql cursor.execute(sql, params) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\utils.py in execute return super().execute(sql, params) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\utils.py in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\utils.py in _execute_with_wrappers return executor(sql, params, many, context) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\utils.py in _execute return self.cursor.execute(sql, params) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\utils.py in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\utils.py in _execute return self.cursor.execute(sql, params) ... ▶ Local vars C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\sqlite3\base.py in execute return Database.Cursor.execute(self, query, params) ... ▶ Local vars Request information USER AnonymousUser GET No GET data POST No POST data FILES No FILES data COOKIES Variable Value csrftoken '5XCUdvt8KVmEXFmXlJVBl3XqrVu8kmXwTO1gxS7hsSVQFLDrJiFjZKgjbEaR89x1' META Variable Value ALLUSERSPROFILE 'C:\\ProgramData' APPDATA 'C:\\Users\\groko\\AppData\\Roaming' COMMONPROGRAMFILES 'C:\\Program Files (x86)\\Common Files' COMMONPROGRAMFILES(X86) 'C:\\Program Files (x86)\\Common Files' COMMONPROGRAMW6432 'C:\\Program Files\\Common Files' COMPUTERNAME 'DESKTOP-OPRI24M' COMSPEC 'C:\\WINDOWS\\system32\\cmd.exe' CONTENT_LENGTH '' CONTENT_TYPE 'text/plain' CSRF_COOKIE '5XCUdvt8KVmEXFmXlJVBl3XqrVu8kmXwTO1gxS7hsSVQFLDrJiFjZKgjbEaR89x1' DJANGO_SETTINGS_MODULE 'djangoject.settings' DRIVERDATA 'C:\\Windows\\System32\\Drivers\\DriverData' EXEPATH 'C:\\Program Files\\Git\\bin' FPS_BROWSER_APP_PROFILE_STRING 'Internet Explorer' FPS_BROWSER_USER_PROFILE_STRING 'Default' GATEWAY_INTERFACE 'CGI/1.1' GROKOKO_DB_PASS 'Jesien2013!' HOME 'C:\\Users\\groko' HOMEDRIVE 'C:' HOMEPATH '\\Users\\groko' HTTP_ACCEPT 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' HTTP_ACCEPT_ENCODING 'gzip, deflate, br' HTTP_ACCEPT_LANGUAGE 'pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6,ja;q=0.5' HTTP_CACHE_CONTROL 'max-age=0' HTTP_CONNECTION 'keep-alive' HTTP_COOKIE 'csrftoken=5XCUdvt8KVmEXFmXlJVBl3XqrVu8kmXwTO1gxS7hsSVQFLDrJiFjZKgjbEaR89x1' HTTP_HOST 'localhost:8000' HTTP_UPGRADE_INSECURE_REQUESTS '1' HTTP_USER_AGENT ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like ' 'Gecko) Chrome/73.0.3683.103 Safari/537.36') LANG 'pl_PL.UTF-8' LOCALAPPDATA 'C:\\Users\\groko\\AppData\\Local' LOGONSERVER '\\\\DESKTOP-OPRI24M' MSYSTEM 'MINGW64' NUMBER_OF_PROCESSORS '4' OLDPWD 'F:/Github/Django' ONEDRIVE 'C:\\Users\\groko\\OneDrive' ONEDRIVECONSUMER 'C:\\Users\\groko\\OneDrive' OS 'Windows_NT' PATH ('C:\\Program Files\\Git\\mingw64\\bin;C:\\Program ' 'Files\\Git\\usr\\bin;C:\\Users\\groko\\bin;C:\\Program Files ' '(x86)\\Python37-32\\Scripts\\;C:\\Program Files ' '(x86)\\Python37-32\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program ' 'Files (x86)\\NVIDIA ' 'Corporation\\PhysX\\Common;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program ' 'Files (x86)\\Microsoft SQL Server\\Client ' 'SDK\\ODBC\\110\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL ' 'Server\\120\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL ' 'Server\\120\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL ' 'Server\\120\\Tools\\Binn\\ManagementStudio\\;C:\\Users\\groko\\AppData\\Local\\Programs\\Python\\Python37-32;C:\\Program ' 'Files (x86)\\Python37-32;C:\\Program Files\\Git\\cmd;C:\\Program ' 'Files\\PostgreSQL\\11\\bin;C:\\Users\\groko\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\groko\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\groko\\AppData\\Local\\Programs\\Microsoft ' 'VS Code\\bin;C:\\Program Files\\heroku\\bin') PATHEXT '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW' PATH_INFO '/' PLINK_PROTOCOL 'ssh' PROCESSOR_ARCHITECTURE 'x86' PROCESSOR_ARCHITEW6432 'AMD64' PROCESSOR_IDENTIFIER 'Intel64 Family 6 Model 42 Stepping 7, GenuineIntel' PROCESSOR_LEVEL '6' PROCESSOR_REVISION '2a07' PROGRAMDATA 'C:\\ProgramData' PROGRAMFILES 'C:\\Program Files (x86)' PROGRAMFILES(X86) 'C:\\Program Files (x86)' PROGRAMW6432 'C:\\Program Files' PS1 ('\\[\\033]0;$TITLEPREFIX:$PWD\\007\\]\\n\\[\\033[32m\\]\\u@\\h ' '\\[\\033[35m\\]$MSYSTEM ' '\\[\\033[33m\\]\\w\\[\\033[36m\\]`__git_ps1`\\[\\033[0m\\]\\n$ ') PSMODULEPATH ('C:\\Program ' 'Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules;C:\\Program ' 'Files (x86)\\Microsoft SQL Server\\120\\Tools\\PowerShell\\Modules\\') PUBLIC 'C:\\Users\\Public' PWD 'F:/Github/Django/Djangoject' QUERY_STRING '' REMOTE_ADDR '127.0.0.1' REMOTE_HOST '' REQUEST_METHOD 'GET' RUN_MAIN 'true' SCRIPT_NAME '' SECRET_KEY 'rp^529&1%^s-8t*9jty*^t#$y164j3$x*q2j%dm!1f5m1(xr-6' SERVER_NAME 'DESKTOP-OPRI24M' SERVER_PORT '8000' SERVER_PROTOCOL 'HTTP/1.1' SERVER_SOFTWARE 'WSGIServer/0.2' SESSIONNAME 'Console' SHLVL '1' SYSTEMDRIVE 'C:' SYSTEMROOT 'C:\\WINDOWS' TEMP 'C:\\Users\\groko\\AppData\\Local\\Temp' TERM 'cygwin' TERM_PROGRAM 'vscode' TERM_PROGRAM_VERSION '1.33.1' TMP 'C:\\Users\\groko\\AppData\\Local\\Temp' USERDOMAIN 'DESKTOP-OPRI24M' USERDOMAIN_ROAMINGPROFILE 'DESKTOP-OPRI24M' USERNAME 'groko' USERPROFILE 'C:\\Users\\groko' WINDIR 'C:\\WINDOWS' _ 'C:/Program Files (x86)/Python37-32/python' wsgi.errors <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'> wsgi.file_wrapper '' wsgi.input <django.core.handlers.wsgi.LimitedStream object at 0x04C3CAB0> wsgi.multiprocess False wsgi.multithread True wsgi.run_once False wsgi.url_scheme 'http' wsgi.version (1, 0) Settings Using settings module djangoject.settings Setting Value ABSOLUTE_URL_OVERRIDES {} ADMINS [] ALLOWED_HOSTS ['0.0.0.0', 'localhost', 'fierce-brook-69212.herokuapp.com'] APPEND_SLASH True AUTHENTICATION_BACKENDS ['django.contrib.auth.backends.ModelBackend'] AUTH_PASSWORD_VALIDATORS '********************' AUTH_USER_MODEL 'auth.User' BASE_DIR 'F:\\Github\\Django\\Djangoject' CACHES {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}} CACHE_MIDDLEWARE_ALIAS 'default' CACHE_MIDDLEWARE_KEY_PREFIX '********************' CACHE_MIDDLEWARE_SECONDS 600 CSRF_COOKIE_AGE 31449600 CSRF_COOKIE_DOMAIN None CSRF_COOKIE_HTTPONLY False CSRF_COOKIE_NAME 'csrftoken' CSRF_COOKIE_PATH '/' CSRF_COOKIE_SAMESITE 'Lax' CSRF_COOKIE_SECURE False CSRF_FAILURE_VIEW 'django.views.csrf.csrf_failure' CSRF_HEADER_NAME 'HTTP_X_CSRFTOKEN' CSRF_TRUSTED_ORIGINS [] CSRF_USE_SESSIONS False DATABASES {'default': {'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.sqlite3', 'HOST': '', 'NAME': 'F:\\Github\\Django\\Djangoject\\db.sqlite3', 'OPTIONS': {}, 'PASSWORD': '********************', 'PORT': '', 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIRROR': None, 'NAME': None}, 'TIME_ZONE': None, 'USER': ''}} DATABASE_ROUTERS [] DATA_UPLOAD_MAX_MEMORY_SIZE 2621440 DATA_UPLOAD_MAX_NUMBER_FIELDS 1000 DATETIME_FORMAT 'N j, Y, P' DATETIME_INPUT_FORMATS ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M', '%Y-%m-%d', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M:%S.%f', '%m/%d/%Y %H:%M', '%m/%d/%Y', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M:%S.%f', '%m/%d/%y %H:%M', '%m/%d/%y'] DATE_FORMAT 'N j, Y' DATE_INPUT_FORMATS ['%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y'] DEBUG True DEBUG_PROPAGATE_EXCEPTIONS False DECIMAL_SEPARATOR '.' DEFAULT_CHARSET 'utf-8' DEFAULT_CONTENT_TYPE 'text/html' DEFAULT_EXCEPTION_REPORTER_FILTER 'django.views.debug.SafeExceptionReporterFilter' DEFAULT_FILE_STORAGE 'django.core.files.storage.FileSystemStorage' DEFAULT_FROM_EMAIL 'webmaster@localhost' DEFAULT_INDEX_TABLESPACE '' DEFAULT_TABLESPACE '' DISALLOWED_USER_AGENTS [] EMAIL_BACKEND 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST 'localhost' EMAIL_HOST_PASSWORD '********************' EMAIL_HOST_USER '' EMAIL_PORT 25 EMAIL_SSL_CERTFILE None EMAIL_SSL_KEYFILE '********************' EMAIL_SUBJECT_PREFIX '[Django] ' EMAIL_TIMEOUT None EMAIL_USE_LOCALTIME False EMAIL_USE_SSL False EMAIL_USE_TLS False FILE_CHARSET 'utf-8' FILE_UPLOAD_DIRECTORY_PERMISSIONS None FILE_UPLOAD_HANDLERS ['django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler'] FILE_UPLOAD_MAX_MEMORY_SIZE 2621440 FILE_UPLOAD_PERMISSIONS None FILE_UPLOAD_TEMP_DIR None FIRST_DAY_OF_WEEK 0 FIXTURE_DIRS [] FORCE_SCRIPT_NAME None FORMAT_MODULE_PATH None FORM_RENDERER 'django.forms.renderers.DjangoTemplates' IGNORABLE_404_URLS [] INSTALLED_APPS ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'articles', 'accounts'] INTERNAL_IPS [] LANGUAGES [('af', 'Afrikaans'), ('ar', 'Arabic'), ('ast', 'Asturian'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('be', 'Belarusian'), ('bn', 'Bengali'), ('br', 'Breton'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('dsb', 'Lower Sorbian'), ('el', 'Greek'), ('en', 'English'), ('en-au', 'Australian English'), ('en-gb', 'British English'), ('eo', 'Esperanto'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-co', 'Colombian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('es-ve', 'Venezuelan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy', 'Frisian'), ('ga', 'Irish'), ('gd', 'Scottish Gaelic'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hsb', 'Upper Sorbian'), ('hu', 'Hungarian'), ('ia', 'Interlingua'), ('id', 'Indonesian'), ('io', 'Ido'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('kab', 'Kabyle'), ('kk', 'Kazakh'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lb', 'Luxembourgish'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('mr', 'Marathi'), ('my', 'Burmese'), ('nb', 'Norwegian Bokmål'), ('ne', 'Nepali'), ('nl', 'Dutch'), ('nn', 'Norwegian Nynorsk'), ('os', 'Ossetic'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('sw', 'Swahili'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('tt', 'Tatar'), ('udm', 'Udmurt'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-hans', 'Simplified Chinese'), ('zh-hant', 'Traditional Chinese')] LANGUAGES_BIDI ['he', 'ar', 'fa', 'ur'] LANGUAGE_CODE 'en-us' LANGUAGE_COOKIE_AGE None LANGUAGE_COOKIE_DOMAIN None LANGUAGE_COOKIE_NAME 'django_language' LANGUAGE_COOKIE_PATH '/' LOCALE_PATHS [] LOGGING {} LOGGING_CONFIG 'logging.config.dictConfig' LOGIN_REDIRECT_URL '/accounts/profile/' LOGIN_URL '/accounts/login/' LOGOUT_REDIRECT_URL None MANAGERS [] MEDIA_ROOT 'F:\\Github\\Django\\Djangoject\\media' MEDIA_URL '/media/' MESSAGE_STORAGE 'django.contrib.messages.storage.fallback.FallbackStorage' MIDDLEWARE ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] MIGRATION_MODULES {} MONTH_DAY_FORMAT 'F j' NUMBER_GROUPING 0 PASSWORD_HASHERS '********************' PASSWORD_RESET_TIMEOUT_DAYS '********************' PREPEND_WWW False ROOT_URLCONF 'djangoject.urls' SECRET_KEY '********************' SECURE_BROWSER_XSS_FILTER False SECURE_CONTENT_TYPE_NOSNIFF False SECURE_HSTS_INCLUDE_SUBDOMAINS False SECURE_HSTS_PRELOAD False SECURE_HSTS_SECONDS 0 SECURE_PROXY_SSL_HEADER None SECURE_REDIRECT_EXEMPT [] SECURE_SSL_HOST None SECURE_SSL_REDIRECT False SERVER_EMAIL 'root@localhost' SESSION_CACHE_ALIAS 'default' SESSION_COOKIE_AGE 1209600 SESSION_COOKIE_DOMAIN None SESSION_COOKIE_HTTPONLY True SESSION_COOKIE_NAME 'sessionid' SESSION_COOKIE_PATH '/' SESSION_COOKIE_SAMESITE 'Lax' SESSION_COOKIE_SECURE False SESSION_ENGINE 'django.contrib.sessions.backends.db' SESSION_EXPIRE_AT_BROWSER_CLOSE False SESSION_FILE_PATH None SESSION_SAVE_EVERY_REQUEST False SESSION_SERIALIZER 'django.contrib.sessions.serializers.JSONSerializer' SETTINGS_MODULE 'djangoject.settings' SHORT_DATETIME_FORMAT 'm/d/Y P' SHORT_DATE_FORMAT 'm/d/Y' SIGNING_BACKEND 'django.core.signing.TimestampSigner' SILENCED_SYSTEM_CHECKS [] STATICFILES_DIRS ('F:\\Github\\Django\\Djangoject\\assets',) STATICFILES_FINDERS ['django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder'] STATICFILES_STORAGE 'django.contrib.staticfiles.storage.StaticFilesStorage' STATIC_ROOT 'F:\\Github\\Django\\Djangoject\\staticfiles' STATIC_URL '/static/' TEMPLATES [{'APP_DIRS': True, 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['djangoject/templates'], 'OPTIONS': {'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages']}}] TEST_NON_SERIALIZED_APPS [] TEST_RUNNER 'django.test.runner.DiscoverRunner' THOUSAND_SEPARATOR ',' TIME_FORMAT 'P' TIME_INPUT_FORMATS ['%H:%M:%S', '%H:%M:%S.%f', '%H:%M'] TIME_ZONE 'UTC' USE_I18N True USE_L10N True USE_THOUSAND_SEPARATOR False USE_TZ True USE_X_FORWARDED_HOST False USE_X_FORWARDED_PORT False WSGI_APPLICATION 'djangoject.wsgi.application' X_FRAME_OPTIONS 'SAMEORIGIN' YEAR_MONTH_FORMAT 'F Y' 时甚至无法运行服务器。当我仅更改数据库设置时,它仍然不好:

datadump > json

小背景:我使用Netninja的Django youtube教程制作了应用。它与在线部署应用程序,隐藏秘密内容或更改数据库没有任何关系,因此我在搜索时可能犯了更多错误。该站点当前在线https://fierce-brook-69212.herokuapp.com/(没有可用的数据库),这里是代码https://github.com/grokoko/Django

编辑。

2 个答案:

答案 0 :(得分:0)

首先删除所有迁移文件, 然后尝试:

  

python manage.py migration --fake

做另一件事使移民迁移

private $objectManager;

public function __construct(ObjectManager $objectManager)
{
    $this->objectManager = $objectManager;

}

答案 1 :(得分:0)

  

当连接到其他数据库后端(例如MySQL,Oracle或PostgreSQL)时,将需要其他连接参数。有关如何指定其他数据库类型,请参见下面的ENGINE设置。此示例适用于PostgreSQL:

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'mydatabase',
    'USER': 'mydatabaseuser',
    'PASSWORD': 'mypassword',
    'HOST': '127.0.0.1',
    'PORT': '5432',
  }
}

然后使用

进行迁移
python manage.py makemigrations
python manage.py migrate

请参见Documentation

要从sqlite迁移到postgres,请参见this Github Gist