question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Version as an environment variable

See original GitHub issue

Description

Right now the version of the project is defined explicitly here: https://github.com/pydanny/cookiecutter-django/blob/master/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py

Rationale

It is possible that I am missing the purpose of the __version__ variable, but it would fit the current structure of the project, if this value was set as an environment variable.

What are your thoughts on this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
luzfcbcommented, Jul 17, 2019

@demestav maybe something like this in your config/settings/base.py

from subprocess import check_output

def get_current_git_tag():
     current_commit_short_hash = check_output("git log -n1 --pretty='%h'".split()).decode().replace("\n", "").replace("'", "")
     return check_output(f"git describe --exact-match --tags {current_commit_short_hash}".split()).decode().replace("\n", "").replace("'", "")

CURRENT_GIT_TAG = get_current_git_tag()
0reactions
demestavcommented, Jul 17, 2019

@luzfcb Thank you for the insightful information! Indeed what you describe is what I want to achieve. How would you go and define the version variable to the git tag? This is where I thought the environment variable fits in; it is set before the application starts to the appropriate value which is then injected in the Django application.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create and Modify Environment Variables on Windows
To create or modify environment variables on Windows 10: On the Windows taskbar, right-click the Windows icon and select System. In the Settings...
Read more >
Environment variable
An environment variable is a dynamic-named value that can affect the way running processes will behave on a computer. They are part of...
Read more >
How do I set or change the PATH system variable?
Click Environment Variables. In the section System Variables find the PATH environment variable and select it. Click Edit. If the PATH environment variable...
Read more >
Environments and versions
Environment variables are key-value pairs you can manage via the Forge CLI ... Forge app version numbers are handled automatically by the ...
Read more >
Environment variables
Learn how to set environment variables for Android Studio and the command-line tools that specify things like where the SDK is installed and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found