djangogithubgitignore

.gitignore file in django


i should do a push of my small project in django/redis and python on github but i noticed that after creating some users and doing the push, they are also saved on github. Reading on the internet I should create a gitignore file but I don't know what to write in it. I should obviously save the migrations but not the data that has been entered in the database. i found a file on gitignore.io but i am not sure if everything in it fits my case. do you have any tips or sites where i can check this?


Solution

  • This is how I have written .gitignore for one of my project built on Django and using Redis server for cache management. I hope it could help you to get idea of what you might need to add.

    venv/
        .env
        __pycache__
        .vscode/
        static_cdn/
        media/*
        ### Python template
        # Byte-compiled / optimized / DLL files
        __pycache__/
        *.py[cod]
        *$py.class
        
        # C extensions
        *.so
        
        # Distribution / packaging
        .Python
        env/
        build/
        develop-eggs/
        dist/
        downloads/
        eggs/
        .eggs/
        lib/
        lib64/
        parts/
        sdist/
        var/
        *.egg-info/
        .installed.cfg
        *.egg
        
        # PyInstaller
        #  Usually these files are written by a python script from a template
        #  before PyInstaller builds the exe, so as to inject date/other infos into it.
        *.manifest
        *.spec
        
        # Installer logs
        pip-log.txt
        pip-delete-this-directory.txt
        
        # Unit test / coverage reports
        htmlcov/
        .tox/
        .coverage
        .coverage.*
        .cache
        nosetests.xml
        coverage.xml
        *,cover
        .hypothesis/
        
        # Translations
        *.mo
        *.pot
        
        # Django stuff:
        *.log
        local_settings.py
        
        # Flask stuff:
        instance/
        .webassets-cache
        
        # Scrapy stuff:
        .scrapy
        
        # Sphinx documentation
        docs/_build/
        
        # PyBuilder
        target/
        
        # IPython Notebook
        .ipynb_checkpoints
        
        # pyenv
        .python-version
        
        # celery beat schedule file
        celerybeat-schedule
        
        
        
        # Spyder project settings
        .spyderproject
        
        # Rope project settings
        .ropeproject
        
        db.sqlite3