5

This is probably a very dumb question. But I have a little project in Django and I would like to upload it to GitHub to just have it there. I know how GitHub works and I know how to upload the project. But I'm wondering if just uploading the whole folder is the right way to do it. I mean. I have a data base with my project, that has some information. So is the database JUST in my computer right? It won't get uploaded next to the project to github?

So basically I'm asking:

  1. Should I just simply upload the whole folder?
  2. And if I were to download my project from GitHub from another computer. Should I just have to run migrations to make it work locally?
4
  • If the database is sqllite, then add the db.sqlite3 file it to your ignored files (git-scm.com/docs/gitignore) if you don't want to include it in your github version. Yes, to the migrations question. Make sure you use something like environment variables for any secrets so you don't mistakenly upload credentials to github. Commented Jun 20, 2021 at 23:59
  • so maybe don't upload the folder, but use the git commands to add, commit and push. dont-be-afraid-to-commit.readthedocs.io/en/latest/git/… Commented Jun 21, 2021 at 0:01
  • @AMG Oh yes I have a sqlite database so I'll add it to the ignored files as you said. What do you mean by secrets and uploading credentials? Thanks for your answer!!! Commented Jun 21, 2021 at 0:16
  • 1
    so if you've got any usernames or passwords stored in your settings.py file or elsewhere , you don't want those on github (like if your email user/password are there, or an api token for a third party site). Use something like Environs to remove them from your source code. Commented Jun 21, 2021 at 0:31

1 Answer 1

4

Don't push your settings.py into a repository, because it has some important information about your application such as SECRET_KEY OR DATABASE.

It’s important to keep your application credentials like API Keys, Amazon S3, email parameters, database parameters safe, specially if it’s an open source repository.

You need to make sure that these kind of information will be stored in a secure place and don't push it into a public repository.

There are more files that you shouldn't push into your repository. check out this link to know more about .gitignore files in Django projects. also there is a website that you can create your .gitignore files automatically.

Now if you want to know more about how to store these kind of informations you can use environment variables and also there is a package called python-decouple that you can use it for storing your important informations.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for answering! I'll definitely check out the environment variables for future projects. Since this project is just a small practice I'm doing I don't think I have many secret information there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.