简体   繁体   English

为什么我的 Django 登录可以在开发服务器上运行而不是在生产服务器上运行?

[英]Why does my Django login work on development server but not production server?

I have an issue where I can login to Django via my development server but it will not work on the production server.我有一个问题,我可以通过我的开发服务器登录到 Django,但它不能在生产服务器上工作。 I am using Heroku to deploy.我正在使用 Heroku 进行部署。 All the pages work correctly but I can't login to my Django database.所有页面都正常工作,但我无法登录到我的 Django 数据库。

Your user credentials are stored in your database.您的用户凭据存储在您的数据库中。 If you have a different database Server in Production which is hosted online it won't have the credentials stored that you have in your local development database.如果您在生产中拥有一个在线托管的不同数据库服务器,它将不会存储您在本地开发数据库中拥有的凭据。

So you basically have to get into your deployed Django app using ssh or so and run „createsuperuser“ there again.所以你基本上必须使用 ssh 左右进入你部署的 Django 应用程序,然后再次在那里运行“createsuperuser”。 Alternatively you could copy the user credentials from you local database and push them to your production database;或者,您可以从本地数据库复制用户凭据并将它们推送到您的生产数据库; but just creating new ones will probably be easier if you don't have to deal with a lot of users.但如果您不必与大量用户打交道,那么创建新的可能会更容易。

If you were using Django with „default settings“ it is using an SQLite file (= database).如果您在“默认设置”下使用 Django,则它使用的是 SQLite 文件(= 数据库)。 In Production for a Webapp hosted online it will be most likely a „real database server” (DBMS) like PostgreSQL or MySQL or so as SQLite is fine for development and testing, but struggles with concurrent user access to data.在在线托管的 Web 应用程序的生产中,它很可能是一个“真正的数据库服务器”(DBMS),如 PostgreSQL 或 MySQL 等,因为 SQLite 适合开发和测试,但难以并发用户访问数据。

If you are configured different database in your production server you have to execute migrations and createsuperuser.如果您在生产服务器中配置了不同的数据库,则必须执行迁移和创建超级用户。 Then you'll able to login.然后就可以登录了。

Your current user credentials are saved in your database which is configured in local server.您当前的用户凭据保存在本地服务器中配置的数据库中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的Gunicorn会监听实时服务器上的本地Django开发服务器 - Why does my gunicorn listen to my local Django development server on my live server 如何使django应用在开发服务器中使用sqlite而不在生产服务器上使用sqlite - How can I make my django app use sqlite in the development server but not on to production server 为什么 Django/Python 请求在生产服务器上不起作用? - Why Django/Python request doesn't work from production server? gzip在开发服务器上可以工作吗? - Does gzip work on the development server? 为什么我的django开发服务器在本地运行的速度要比在Heroku上运行同一开发服务器的速度快得多? - Why is my django development server running locally so much faster then running the same development server on Heroku? 如何使网站与Django开发服务器兼容? - How to make a website work with Django development server? 为什么詹金斯启动我的django服务器会给我404,但手动运行相同的脚本才能正常工作? - Why does Jenkins starting my django server give me 404, but manually running the same script work properly? 为什么我不能使用 Django 服务器进行生产? - Why can I not use the Django server for production? 何时以及为何使用Django开发服务器? - When and why to use Django development server? 为什么我应该切换到 flask 生产部署而不是开发服务器? - Why should I switch to a flask production deployment instead of a development server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM