What type files should be put into .gitignore file in Django project

Viewed 9665

From my other post, I know the __pycache__ should be put into the .gitignore when I use git.

And in the other post I saw, there are also .pyc and .pyo files.

whether them should all be put into the .gitignore file?

Can we summarize in the Python/Django project, what files should be put into . gitignore file?

1 Answers

There is a popular web service called Gitignore.io that help developers generate gitignore files for popular framework and languages. You can see the Django one here.

*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
media

On top of that I would also recommend you to ignore things environment items such as virtualenv, or .env files that are related to the local environment that the code is being run from. This also allow you to store passwords and secrets in environment files, and keep them out of your git repo.

.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

Lastly I would also add the django static folder to the list of files to ignore since it is collected with collectstatic whenever you deploy your code.

Related