Search code examples
pythondjangobashterminalpipenv

When I install django with pipenv, which approach is better?


When installing packages and other things in project like django, is declaring a version good or bad?

pipenv install django

or

pipenv install django==3.1.0

Solution

  • If you're developing an application (which I'm assuming you are since you're using Django), it's best practice to pin your dependencies to ensure safe, repeatable builds and that future releases work when you developed it. Typically this is done in a requirements.txt file, which can be automatically generated via pip freeze > requirements.txt.

    If you're developing a library, it's still recommended to pin the dependencies, but with looser constraints (e.g. ~=3.1.0 or >=3.1.0 instead of ==3.1.0).

    See here for further discussions on this topic.