如何防止Django“忘记”密码?每当我提交Git时都会得到信息吗? [英] How can I prevent Django from "forgetting" information whenever I make a Git commit?

查看:102
本文介绍了如何防止Django“忘记”密码?每当我提交Git时都会得到信息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Django中的一个博客项目上工作,该项目当前正在生产中运行。我一直在对开发版本进行更改,当我在Git上进行更改时,我注意到每次提交都会清除我存储在生产服务器中的信息。具体来说,a)在生产服务器上写的某些博客文章,以及b)每当我进行新提交时,在生产服务器上添加的用户帐户似乎消失。

I am working on a blog project in Django that I currently have a version running in production. I have been making changes to the Development version and as I push through the changes on Git I notice that every commit "clears" information I had stored in the production server. To be specific, a) certain blog posts that were written on the production server and b) user 'accounts' added on the production server seem to "disappear" whenever I push through new commits.

有人告诉我,这个问题可能是由于我使用sqlite(我使用sqlite3)以及本地开发数据库与存储库混合造成的。如果是这种情况,我该如何解决此问题。如果您怀疑这是由另一个问题引起的,可能是什么原因?

I was told that this problem is potentially due to my usage of sqlite (I use sqlite3) and my local dev database getting "mixed in" with my repository. If this is the case, how can I fix this problem. If you suspect this is due to a different issue, what may be the cause?

尽管我使用Python已有一段时间,但我还是同时使用Django和Git。我非常感谢您提供的所有帮助。为了易于使用,下面是我的文章模型的一部分-文章代表博客文章。

I am new to using both Django and Git though I have used Python for some time. I really appreciate any and all help. For ease of use, part of my "Articles" model is below - the articles represent blog posts.

class Article(models.Model):
    title = models.CharField(max_length=255)
    #Body is the "body" of our entry - self explanatory. 
    body = models.TextField()
    #date = models.DateTimeField(auto_now_add=True)
    author = models.ForeignKey(
        get_user_model(),
        on_delete=models.CASCADE, 
    )


推荐答案

添加一个将 .gitignore 文件添加到您的仓库中,在其中添加 *。sqlite3 行,并运行以下 git rm --cached * .sqlite3

add a .gitignore file to your repo, add the line *.sqlite3 to it, run the following git rm --cached *.sqlite3

您的整个数据库都位于sqlite文件中。您的仓库中目前有一个开发人员正在跟踪该仓库。每次在开发和提交中进行更改时,它都会用您的开发数据库覆盖prod数据库。

Your entire database is in the sqlite file. You have one in dev that is currently tracked by your repo. Every time you make a change in dev and commit, it overwrites your prod database with your dev database.

这篇关于如何防止Django“忘记”密码?每当我提交Git时都会得到信息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆